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