Struct httpbis::ServicePaths [−][src]
pub struct ServicePaths { /* fields omitted */ }
Convient implementation of Service
which allows delegation to
multiple Service
implementations provided by user.
Methods
impl ServicePaths
[src]
impl ServicePaths
pub fn new() -> ServicePaths
[src]
pub fn new() -> ServicePaths
Create a new Service
implementation which returns 404
on all requests by default.
pub fn set_service(&mut self, path: &str, service: Arc<Service>)
[src]
pub fn set_service(&mut self, path: &str, service: Arc<Service>)
Register a service for given path.
use httpbis::*; struct Root {} struct Files {} impl Service for Root { fn start_request(&self, _headers: Headers, _req: HttpStreamAfterHeaders) -> Response { Response::found_200_plain_text("This is root page") } } impl Service for Files { fn start_request(&self, _headers: Headers, _req: HttpStreamAfterHeaders) -> Response { Response::found_200_plain_text("This is files") } } 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(Headers, HttpStreamAfterHeaders) -> Response + Send + Sync + 'static,
[src]
pub fn set_service_fn<F>(&mut self, path: &str, service: F) where
F: Fn(Headers, HttpStreamAfterHeaders) -> Response + Send + Sync + 'static,
pub fn remove_service(&mut self, path: &str) -> Option<Arc<Service>>
[src]
pub fn remove_service(&mut self, path: &str) -> Option<Arc<Service>>
Trait Implementations
impl Default for ServicePaths
[src]
impl Default for ServicePaths
fn default() -> ServicePaths
[src]
fn default() -> ServicePaths
Returns the "default value" for a type. Read more
impl Service for ServicePaths
[src]
impl Service for ServicePaths
fn start_request(
&self,
headers: Headers,
req: HttpStreamAfterHeaders
) -> Response
[src]
fn start_request(
&self,
headers: Headers,
req: HttpStreamAfterHeaders
) -> Response
Start HTTP/2 request. Read more
Auto Trait Implementations
impl Send for ServicePaths
impl Send for ServicePaths
impl Sync for ServicePaths
impl Sync for ServicePaths