refactor(service): change service_fn to take Fn instead of FnMut
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
//!
|
//!
|
||||||
//! There are two levels of APIs provide for constructing HTTP servers:
|
//! There are two levels of APIs provide for constructing HTTP servers:
|
||||||
//!
|
//!
|
||||||
//! - The higher-level [`Server`](Server).
|
//! - The higher-level [`Server`](Server) type.
|
||||||
//! - The lower-level [conn](conn) module.
|
//! - The lower-level [conn](conn) module.
|
||||||
//!
|
//!
|
||||||
//! # Server
|
//! # Server
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ pub trait Service {
|
|||||||
/// ```
|
/// ```
|
||||||
pub fn service_fn<F, R, S>(f: F) -> ServiceFn<F, R>
|
pub fn service_fn<F, R, S>(f: F) -> ServiceFn<F, R>
|
||||||
where
|
where
|
||||||
F: FnMut(Request<R>) -> S,
|
F: Fn(Request<R>) -> S,
|
||||||
S: IntoFuture,
|
S: IntoFuture,
|
||||||
{
|
{
|
||||||
ServiceFn {
|
ServiceFn {
|
||||||
@@ -75,7 +75,7 @@ where
|
|||||||
/// ```
|
/// ```
|
||||||
pub fn service_fn_ok<F, R, S>(f: F) -> ServiceFnOk<F, R>
|
pub fn service_fn_ok<F, R, S>(f: F) -> ServiceFnOk<F, R>
|
||||||
where
|
where
|
||||||
F: FnMut(Request<R>) -> Response<S>,
|
F: Fn(Request<R>) -> Response<S>,
|
||||||
S: Payload,
|
S: Payload,
|
||||||
{
|
{
|
||||||
ServiceFnOk {
|
ServiceFnOk {
|
||||||
@@ -92,7 +92,7 @@ pub struct ServiceFn<F, R> {
|
|||||||
|
|
||||||
impl<F, ReqBody, Ret, ResBody> Service for ServiceFn<F, ReqBody>
|
impl<F, ReqBody, Ret, ResBody> Service for ServiceFn<F, ReqBody>
|
||||||
where
|
where
|
||||||
F: FnMut(Request<ReqBody>) -> Ret,
|
F: Fn(Request<ReqBody>) -> Ret,
|
||||||
ReqBody: Payload,
|
ReqBody: Payload,
|
||||||
Ret: IntoFuture<Item=Response<ResBody>>,
|
Ret: IntoFuture<Item=Response<ResBody>>,
|
||||||
Ret::Error: Into<Box<StdError + Send + Sync>>,
|
Ret::Error: Into<Box<StdError + Send + Sync>>,
|
||||||
@@ -133,7 +133,7 @@ pub struct ServiceFnOk<F, R> {
|
|||||||
|
|
||||||
impl<F, ReqBody, ResBody> Service for ServiceFnOk<F, ReqBody>
|
impl<F, ReqBody, ResBody> Service for ServiceFnOk<F, ReqBody>
|
||||||
where
|
where
|
||||||
F: FnMut(Request<ReqBody>) -> Response<ResBody>,
|
F: Fn(Request<ReqBody>) -> Response<ResBody>,
|
||||||
ReqBody: Payload,
|
ReqBody: Payload,
|
||||||
ResBody: Payload,
|
ResBody: Payload,
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user