pub fn handler_sync_service<Arg, F, T, O>(
    func: F
) -> FnService<impl Fn(Arg) -> Ready<Result<HandlerServiceSync<F, T, O>, Infallible>>>
where F: Closure<T> + Send + Clone,
Expand description

synchronous version of handler_service

handler_sync_service run given function on a separate thread pool from the event loop and async logic of xitca-web itself. Therefore it comes with different requirement of function argument compared to handler_service where the arguments must be types that impl FromRequest trait, being thread safe with Send trait bound and with 'static lifetime.

Examples:


App::new()
    .at("/valid", handler_sync_service(|_: UriOwn| "uri is thread safe and owned value"))
    // uncomment the line below would result in compile error.
    // .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" }))