[−][src]Trait hightide::Responder
This trait is implemented for all the common types you can return from an endpoint
It's also implemented for tide::Response
and hightide::Response
for compatibility.
There is an implementation for tide::Result<R> where R: Responder
which allows fallible
functions to be used as endpoints
use hightide::{Responder, Json}; use tide::{StatusCode, Request}; fn example_1(_: Request<()>) -> impl Responder { // return status code StatusCode::NotFound } fn example_2(_: Request<()>) -> impl Responder { // return strings (&str or String) "Hello World" } fn example_3(_: Request<()>) -> impl Responder { // return status code with data (StatusCode::NotFound, "Not found!") } fn example_4(_: Request<()>) -> impl Responder { // return JSON data - for any type implementing `serde::Serialize` Json(MyData{ id: 0, key: "foo"}) } fn example_5(_: Request<()>) -> tide::Result<impl Responder> { // fallible functions too // (also works the return type as `impl Responder` as long as Rust can infer the function returns `tide::Result`) Ok((StatusCode::Conflict, "Already Exists")) }
Required methods
fn into_response(self) -> Result<Response>
Implementations on Foreign Types
impl Responder for StatusCode
[src]
fn into_response(self) -> Result<Response>
[src]
impl Responder for String
[src]
fn into_response(self) -> Result<Response>
[src]
impl<'_> Responder for &'_ str
[src]
fn into_response(self) -> Result<Response>
[src]
impl<'_> Responder for &'_ [u8]
[src]
fn into_response(self) -> Result<Response>
[src]
impl<R> Responder for (StatusCode, R) where
R: Responder,
[src]
R: Responder,
fn into_response(self) -> Result<Response>
[src]
impl Responder for Response
[src]
fn into_response(self) -> Result<Response>
[src]
impl<R> Responder for Result<R> where
R: Responder,
[src]
R: Responder,