Struct hyper_fast::server::HttpResponse
source · 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 75)
65 66 67 68 69 70 71 72 73 74 75 76 77
async fn api_handler<'a>(
&'a self,
_: Body,
route: &HttpRoute<'a>,
path: &[&str],
) -> Result<Response<Body>, ApiError> {
match path {
["test"] if matches!(route.method, &http::Method::GET) => {
self.get_test(route).await
}
_ => HttpResponse::not_found(route.path),
}
}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 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