The response is an RFC 9457 problem document with this status and, when detail is given, a
detail that contains it. Returns the decoded document (empty when the check failed).
- status: the status the problem must have.
- detail: the text the
detailmember must have. Empty skips that check.
find :: (id: Path("id", int)) -> string, Http_Error {
return "", not_found("No note %", id.value);
}
main :: () {
app: App;
defer free_app(*app);
get(*app, "/notes/{id}", find);
api := test_client(*app);
response, _ := get(api, "/notes/9");
defer close(*response);
problem := expect_problem(response, 404, "No note 9");
assert(problem.title == "Not Found");
}Doesn't run in the browser (skipped on wasm).
expect_problem :: (
response: Client_Response,
status: int,
detail := "",
loc := #caller_location
) -> Problem
The response is an RFC 9457 problem document with this status and, when detail is given, a
detail that contains it. Returns the decoded document (empty when the check failed).
Parameters
- response: Client_Response
- status: int
- the status the problem must have.
- detail := ""
- the text the
detailmember must have. Empty skips that check. - loc := #caller_location
Returns
find :: (id: Path("id", int)) -> string, Http_Error {
return "", not_found("No note %", id.value);
}
main :: () {
app: App;
defer free_app(*app);
get(*app, "/notes/{id}", find);
api := test_client(*app);
response, _ := get(api, "/notes/9");
defer close(*response);
problem := expect_problem(response, 404, "No note 9");
assert(problem.title == "Not Found");
}Doesn't run in the browser (skipped on wasm).