pub struct HttpResponse;
Implementations§
Source§impl HttpResponse
impl HttpResponse
pub fn internal_server_error(error: Error) -> HttpResult
Sourcepub fn not_found(reason: &str) -> HttpResult
pub fn not_found(reason: &str) -> HttpResult
Examples found in repository?
examples/example_server.rs (line 63)
53 async fn api_handler<'a>(
54 &'a self,
55 _: Body,
56 route: &HttpRoute<'a>,
57 path: &[&str],
58 ) -> Result<Response<Body>, ApiError> {
59 match path {
60 ["test"] if matches!(route.method, &http::Method::GET) => {
61 self.get_test(route).await
62 }
63 _ => HttpResponse::not_found(route.path),
64 }
65 }
pub fn forbidden(reason: &str) -> HttpResult
pub fn bad_request(error: Error) -> HttpResult
pub fn no_content(reason: &str) -> HttpResult
pub fn ok(route: &HttpRoute<'_>, body: Body) -> HttpResult
Sourcepub fn string(route: &HttpRoute<'_>, body: String) -> HttpResult
pub fn string(route: &HttpRoute<'_>, body: String) -> HttpResult
pub fn str(route: &HttpRoute<'_>, body: &'static str) -> HttpResult
pub fn json<S>(route: &HttpRoute<'_>, body: &S) -> HttpResultwhere
S: Serialize,
pub fn proto_binary(route: &HttpRoute<'_>, body: Vec<u8>) -> HttpResult
pub fn binary_or_json<S>(route: &HttpRoute<'_>, body: &S) -> HttpResultwhere
S: Serialize,
pub fn from_vec<S>(route: &HttpRoute<'_>, body: Vec<u8>) -> HttpResultwhere
S: Serialize,
pub fn compress_response( route: &HttpRoute<'_>, response: Response<Body>, ) -> Response<Body>
Auto Trait Implementations§
impl Freeze for HttpResponse
impl RefUnwindSafe for HttpResponse
impl Send for HttpResponse
impl Sync for HttpResponse
impl Unpin for HttpResponse
impl UnwindSafe for HttpResponse
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more