[go: up one dir, main page]

Function service

Source
pub fn service<F>(filter: F) -> FilteredService<F>
where F: Filter, <F::Future as TryFuture>::Ok: Reply, <F::Future as TryFuture>::Error: IsReject,
Expand description

Convert a Filter into a Service.

Filters are normally what APIs are built on in warp. However, it can be useful to convert a Filter into a Service, such as if further customizing a hyper::Service, or if wanting to make use of the greater Tower set of middleware.

ยงExample

Running a warp::Filter on a regular hyper::Server:

use std::convert::Infallible;
use warp::Filter;

// Our Filter...
let route = warp::any().map(|| "Hello From Warp!");

// Convert it into a `Service`...
let svc = warp::service(route);