[−][src]Struct httpbis::ServerHandlerPaths
Convient implementation of ServerHandler
which allows delegation to
multiple ServerHandler
implementations provided by user.
Implementations
impl ServerHandlerPaths
[src]
pub fn new() -> ServerHandlerPaths
[src]
Create a new Service
implementation which returns 404
on all requests by default.
pub fn set_service(&mut self, path: &str, service: Arc<dyn ServerHandler>)
[src]
Register a service for given path.
struct Root {} struct Files {} impl ServerHandler for Root { fn start_request(&self, _context: ServerHandlerContext, _req: ServerRequest, mut resp: ServerResponse) -> httpbis::Result<()> { resp.send_found_200_plain_text("This is root page")?; Ok(()) } } impl ServerHandler for Files { fn start_request(&self, _context: ServerHandlerContext, _req: ServerRequest, mut resp: ServerResponse) -> httpbis::Result<()> { resp.send_found_200_plain_text("This is files")?; Ok(()) } } let mut server = ServerBuilder::new_plain(); server.service.set_service("/", Arc::new(Root{})); server.service.set_service("/files", Arc::new(Files{}));
pub fn set_service_fn<F>(&mut self, path: &str, service: F) where
F: Fn(ServerHandlerContext, ServerRequest, ServerResponse) -> Result<()> + Send + Sync + 'static,
[src]
F: Fn(ServerHandlerContext, ServerRequest, ServerResponse) -> Result<()> + Send + Sync + 'static,
pub fn remove_service(&mut self, path: &str) -> Option<Arc<dyn ServerHandler>>
[src]
Trait Implementations
impl Default for ServerHandlerPaths
[src]
fn default() -> ServerHandlerPaths
[src]
impl ServerHandler for ServerHandlerPaths
[src]
fn start_request(
&self,
context: ServerHandlerContext,
req: ServerRequest,
resp: ServerResponse
) -> Result<()>
[src]
&self,
context: ServerHandlerContext,
req: ServerRequest,
resp: ServerResponse
) -> Result<()>
Auto Trait Implementations
impl !RefUnwindSafe for ServerHandlerPaths
impl Send for ServerHandlerPaths
impl Sync for ServerHandlerPaths
impl Unpin for ServerHandlerPaths
impl !UnwindSafe for ServerHandlerPaths
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,
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.
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>,