pub enum Handler {
Static(Response),
Dynamic(Arc<dyn Fn(&Request) -> Response + Send + Sync>),
}Expand description
A handler that returns either a static or dynamic HTTP response
Variants§
Static(Response)
Static response - always returns the same response
Dynamic(Arc<dyn Fn(&Request) -> Response + Send + Sync>)
Dynamic response - builds response based on the request
Implementations§
Source§impl Handler
impl Handler
Sourcepub fn dynamic<F>(f: F) -> Self
pub fn dynamic<F>(f: F) -> Self
Create a dynamic handler that builds responses based on the request
Sourcepub fn with_status(self, status: u16) -> Self
pub fn with_status(self, status: u16) -> Self
Modify the status code (only works for static handlers, returns a new static handler)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Handler
impl !RefUnwindSafe for Handler
impl Send for Handler
impl Sync for Handler
impl Unpin for Handler
impl !UnwindSafe for Handler
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