trillium_api/lib.rs
1/*!
2This crate provides handlers for common http api behavior.
3
4Eventually, some of this crate may move into the trillium crate, but
5for now it exists separately for ease of iteration. Expect more
6breaking changes in this crate then in the trillium crate.
7
8## Formats supported:
9
10Currently, this crate supports *receiving* `application/json` and
11`application/x-form-www-urlencoded` by default. To disable
12`application/x-form-www-urlencoded` support, use `default-features =
13false`.
14
15This crate currently only supports sending json responses, but may
16eventually add `Accepts` negotiation and further outbound response
17content types.
18
19The [`ApiConnExt`] extension trait and [`ApiHandler`] can be used
20independently or in combination.
21
22[`ApiHandler`] provides a different and more experimental interface to writing trillium handlers,
23with different performance and ergonomic considerations.
24*/
25#![forbid(unsafe_code)]
26#![deny(
27 missing_copy_implementations,
28 rustdoc::missing_crate_level_docs,
29 missing_debug_implementations,
30 missing_docs,
31 nonstandard_style,
32 unused_qualifications
33)]
34
35mod api_conn_ext;
36mod api_handler;
37mod before_send;
38mod body;
39mod cancel_on_disconnect;
40mod error;
41mod from_conn;
42mod halt;
43mod json;
44mod state;
45mod try_from_conn;
46
47pub use api_conn_ext::ApiConnExt;
48pub use api_handler::{api, ApiHandler};
49pub use before_send::BeforeSend;
50pub use body::Body;
51pub use cancel_on_disconnect::{cancel_on_disconnect, CancelOnDisconnect};
52pub use error::Error;
53pub use from_conn::FromConn;
54pub use halt::Halt;
55pub use json::Json;
56pub use serde_json::{json, Value};
57pub use state::State;
58pub use try_from_conn::TryFromConn;
59
60/// trait alias for a result with this crate's [`Error`]
61pub type Result<T> = std::result::Result<T, Error>;