Expand description
A router implementation that can handle requests in a type safe way, while also allowing information about the routes, route descriptions and expected input and output types to be automatically generated from it.
Structs
The entry point; you can create an instance of this and then add API routes to it
using
Self::add()
. You can then get information about the routes that have been added
using Self::info()
, or handle an http::Request
using Self::handle()
.A representation of some type, including its description and shape.
This is given back for anything which implements the
crate::ApiBody
trait,
and is automatically generated if one uses the crate::ApiBody
macro on some type.This represents an API error that is returned from the API.
Add a new API route by providing a description (optional but encouraged)
and then a handler function.
Information about a single route.
Enums
An enum representing the shape of the JSON that is provided or output from the API.
There is a straightforward mapping from this to TypeScript types.
A route is either not found, or we attempted to run it and ran into
an issue.
Traits
Any type that implements this trait can be described in terms of
ApiBodyInfo
, and
can potentially also be serialized or deserizlied from JSON.Attribute Macros
Use this macro to generate serde
Serialize
/Deserialize
impls in addition
to an ApiBody
impl that can hand back information about the shape of the
type.Derive Macros
Use this macro to generate an
Into<ApiError>
implementation for your custom error
type. Your custom error type needs to implement Debug
and Display
in order to
derive ApiError
. Display
in particular determines what the error message will be.
You can then use attribtues to set the status code, and decide on whether the
error message will be internal
-only or external
.