Response
Overview
The Response
enum has the following three variants:
Response
is the required response type for every route hanlder.
An example of basic route handler is:
API handlers
#[tuono_lib::api(method)]
must not return theResponse
enum. The API handler should implement any allowed axum response type.
Response::Props
Allows the handler to pass data to the React route,
which will be available in the data
prop of the corresponding route.
The Response::Props
variant takes a Props
struct as its first argument,
which represents the data.
The data passed as prop have to implement both
Serialize
andDeserialize
from the serde crate.
Response::Redirect
Allows the server to redirect the current request to a given path. For example:
Response::Custom
This variant allows the route handler to skip server-side rendering in ReactJS and return the passed values instead.
For example, to generate the app's sitemaps and return an .xml
file,
we could write the following handler: