catcher: Add trailing newline to body text

Since the API provided by this service is intended to be used on the
command line e.g. with `curl`, we need our responses to have a trailing
newline.  This ensures that, when used interactively, the next shell
prompt is correctly placed on a new line, and when used
non-interactively, line-buffered output is correctly flushed (i.e. to a
log file).
master
Dustin 2025-09-23 14:59:01 -05:00
parent 6f7160fc02
commit 2a10c815be
2 changed files with 3 additions and 3 deletions

View File

@ -4,8 +4,8 @@ use rocket::http::Status;
#[rocket::catch(default)]
fn not_found(status: Status, _req: &Request) -> String {
match status.reason() {
Some(s) => s.into(),
None => format!("{}", status.code),
Some(s) => format!("{s}\n"),
None => format!("{}\n", status.code),
}
}

View File

@ -17,5 +17,5 @@ fn test_not_found() {
let client = super::client();
let response = client.get("/bogus").dispatch();
assert_eq!(response.status(), Status::NotFound);
assert_eq!(response.into_string(), Some("Not Found".into()));
assert_eq!(response.into_string(), Some("Not Found\n".into()));
}