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]

Create a new Service implementation which returns 404 on all requests by default.

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{}));

Trait Implementations

impl Default for ServicePaths
[src]

Returns the "default value" for a type. Read more

impl Service for ServicePaths
[src]

Start HTTP/2 request. Read more

Auto Trait Implementations