Struct seamless::api::RouteBuilder [−][src]
Add a new API route by providing a description (optional but encouraged) and then a handler function.
Examples
// This route expects a JSON formatted string to be provided, and echoes it straight back. api.add("some/route/name") .description("This route takes some Foo's in and returns some Bar's") .handler(|body: Json<String>| async move { Ok::<_,std::convert::Infallible>(body.json) }); // This route delegates to an async fn to sum some values, so we can infer more types in the handler. api.add("another.route") .description("This route takes an array of values and sums them") .handler(|body: Json<_>| sum(body.json)); async fn sum(ns: Vec<u64>) -> Result<u64, Infallible> { Ok(ns.into_iter().sum()) }
Implementations
impl<'a> RouteBuilder<'a>
[src]
pub fn description<S: Into<String>>(self, desc: S) -> Self
[src]
Add a description to the API route.
pub fn handler<A, HandlerFn: IntoHandler<ApiError, A>>(self, handler: HandlerFn)
[src]
Add a handler to the API route. Until this has been added, the route doesn't "exist".
Auto Trait Implementations
impl<'a> !RefUnwindSafe for RouteBuilder<'a>
[src]
impl<'a> Send for RouteBuilder<'a>
[src]
impl<'a> Sync for RouteBuilder<'a>
[src]
impl<'a> Unpin for RouteBuilder<'a>
[src]
impl<'a> !UnwindSafe for RouteBuilder<'a>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,