Function poem::endpoint::make [−][src]
pub fn make<F, Fut, R>(f: F) -> impl Endpoint<Output = R> where
F: Fn(Request) -> Fut + Send + Sync,
Fut: Future<Output = R> + Send,
R: IntoResponse,
Expand description
Create an endpoint with a asyncness function.
Example
use poem::{endpoint::make, http::Method, Endpoint, Request};
let ep = make(|req| async move { req.method().to_string() });
let resp = ep
.call(Request::builder().method(Method::GET).finish())
.await;
assert_eq!(resp, "GET");