Adds a PATCH route; the template, handler and max_body work as for get.
touch :: (id: Path("id", int)) -> Response {
return status_only(204);
}
main :: () {
app: App;
defer free_app(*app);
patch(*app, "/items/{id}", touch);
api := test_client(*app);
response, _ := patch(api, "/items/3", "changed");
defer close(*response);
assert(response.status == 204);
}Doesn't run in the browser (skipped on wasm).
patch :: (
app: *App,
$template: string,
$handler: $H,
max_body := 0,
$loc := #caller_location
)
Parameters
- app: *App
- $template: string
- $handler: $H
- max_body := 0
- $loc := #caller_location
patch :: (
group: *Group($P),
$template: string,
$handler: $H,
max_body := 0,
$loc := #caller_location
)
The patch for a route under a group's prefix.
Parameters
- group: *Group($P)
- $template: string
- $handler: $H
- max_body := 0
- $loc := #caller_location
patch :: (
client: *Client,
url: string,
value: $V,
headers: [] Header_Field = .[]
) -> (Client_Response, Client_Error)
PATCH with value as a JSON body, as post sends it.
Parameters
- client: *Client
- url: string
- value: $V
- headers: [] Header_Field = .[]
Returns
Change :: struct {
name: string;
}
apply :: (change: Json(Change)) -> Response {
return status_only(204);
}
main :: () {
app: App;
defer free_app(*app);
patch(*app, "/item", apply);
api := test_client(*app);
response, _ := patch(api, "/item", Change.{ name = "pencil" });
defer close(*response);
assert(response.status == 204);
}Doesn't run in the browser (skipped on wasm).