[][src]Function hyper::service::service_fn_ok

pub fn service_fn_ok<F, R, S>(f: F) -> ServiceFnOk<F, R> where
    F: FnMut(Request<R>) -> Response<S>,
    S: Payload

Create a Service from a function that never errors.

Example

use hyper::{Body, Request, Response};
use hyper::service::service_fn_ok;

let service = service_fn_ok(|req: Request<Body>| {
    println!("request: {} {}", req.method(), req.uri());
    Response::new(Body::from("Hello World"))
});