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§
- append_
to_ string - Provide request json in form of
RequestJson
and outputsResponseJson
. Inside function body the input json will be parsed tostate
object. - get_
country - Function calls external RestCountries API and extracts information about given country. Function
expects query parameter in form of
?name=<country_name>
. - get_
json - Return arbitrary json object.
serde_json::Value
can be a valid json object of any kind. Wrapping output aroundaxum::Json
as it implementsIntoResponse
trait. - get_
json_ counter - Return how many times
get_json
has been called. This introduces shared state implemented with Arc and Mutex. - get_
random_ number - Function generates single random number and returns it as
String
.String
is viable output becauseIntoResponse
trait is by default implemented for it.