Module example_webserver_rs::handlers
source · Expand description
In axum a “handler” is an async function that accepts zero or more “extractors” as arguments and returns something that can be converted into a response.
Functions§
- Provide request json in form of
RequestJsonand outputsResponseJson. Inside function body the input json will be parsed tostateobject. - Return arbitrary json object.
serde_json::Valuecan be a valid json object of any kind. Wrapping output aroundaxum::Jsonas it implementsIntoResponsetrait. - Return how many times
get_jsonhas been called. This introduces shared state implemented with Arc and Mutex. - Function generates single random number and returns it as
String.Stringis viable output becauseIntoResponsetrait is by default implemented for it.