diff --git a/web/src/handler/sync.rs b/web/src/handler/sync.rs index 402a8f29..c65c50d7 100644 --- a/web/src/handler/sync.rs +++ b/web/src/handler/sync.rs @@ -1,10 +1,6 @@ #![allow(non_snake_case)] -use core::{ - convert::Infallible, - future::{Ready, ready}, - marker::PhantomData, -}; +use core::{convert::Infallible, marker::PhantomData}; use super::{FromRequest, Responder}; @@ -34,30 +30,30 @@ use xitca_service::{FnService, Service, fn_build}; /// // .at("/invalid1", handler_sync_service(|_: UriRef<'_>| { "uri ref is borrowed value" })) /// // uncomment the line below would result in compile error. /// // .at("/invalid2", handler_sync_service(|_: &WebContext<'_>| { "web request is borrowed value and not thread safe" })) -/// # .at("/nah", handler_service(|_: &WebContext<'_>| async { "" })); +/// # .at("/nah", handler_service(async |_: &WebContext<'_>| { "" })); /// ``` /// /// [handler_service]: super::handler_service -pub fn handler_sync_service(func: F) -> FnService Ready>> +pub fn handler_sync_service(func: F) -> FnService FnServiceOutput> where F: Closure + Send + Clone, { - fn_build(move |_| { - ready(Ok(HandlerServiceSync { + fn_build(async move |_| { + Ok(HandlerServiceSync { func: func.clone(), _p: PhantomData, - })) + }) }) } -type FnServiceOutput = Result, Infallible>; +type FnServiceOutput = Result, Infallible>; -pub struct HandlerServiceSync { +pub struct HandlerServiceSync { func: F, - _p: PhantomData<(T, O)>, + _p: PhantomData, } -impl Service for HandlerServiceSync +impl Service for HandlerServiceSync where // for borrowed extractors, `T` is the `'static` version of the extractors T: FromRequest<'static, Req>,