Expand description
This crate provides handlers for common http api behavior.
Eventually, some of this crate may move into the trillium crate, but for now it exists separately for ease of iteration. Expect more breaking changes in this crate then in the trillium crate.
§Formats supported:
Currently, this crate supports receiving application/json
and
application/x-form-www-urlencoded
by default. To disable
application/x-form-www-urlencoded
support, use default-features = false
.
This crate currently only supports sending json responses, but may
eventually add Accepts
negotiation and further outbound response
content types.
The ApiConnExt
extension trait and ApiHandler
can be used
independently or in combination.
ApiHandler
provides a different and more experimental interface to writing trillium handlers,
with different performance and ergonomic considerations.
Macros§
- json
- Construct a
serde_json::Value
from a JSON literal.
Structs§
- ApiHandler
- An interface layer built on trillium
- Before
Send - Run a [
trillium::Handler
] inbefore_send
- Body
- Body extractor
- Cancel
OnDisconnect - A struct that cancels a handler if the client disconnects.
- Halt
- a struct that halts the Conn handler sequence. see [
Conn::halt
] for more. - Json
- A newtype wrapper struct for any
serde::Serialize
type. Note that this currently must own the serializable type. Body extractor - State
- State extractor
Enums§
Traits§
- ApiConn
Ext - Extension trait that adds api methods to [
trillium::Conn
] - From
Conn - A trait to extract content from [
Conn
]s to be used as the second argument to an api handler. Implement this for your types. - TryFrom
Conn - Like FromConn, but with an Error.
Functions§
- api
- constructs a new [
ApiTryFromConnHandler
] from the providedasync fn(&mut conn, TryFromConn) -> impl Handler
- cancel_
on_ disconnect - Construct a new
CancelOnDisconnect
handler.