mirror of
https://github.com/Start9Labs/rpc-toolkit.git
synced 2026-03-26 02:11:56 +00:00
'mo lifetimes 'mo problems
This commit is contained in:
@@ -100,25 +100,29 @@ pub fn to_response<F: Fn(i32) -> StatusCode>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// &mut Request<Body> -> Result<Result<Future<&mut RpcRequest<...> -> Future<Result<Result<&mut Response<Body> -> Future<Result<(), HttpError>>, Response<Body>>, HttpError>>>, Response<Body>>, HttpError>
|
// &mut Request<Body> -> Result<Result<Future<&mut RpcRequest<...> -> Future<Result<Result<&mut Response<Body> -> Future<Result<(), HttpError>>, Response<Body>>, HttpError>>>, Response<Body>>, HttpError>
|
||||||
pub type DynMiddleware<'a, 'b, 'c, Params> = Box<
|
pub type DynMiddleware<Params> = Box<
|
||||||
dyn FnOnce(
|
dyn for<'a> FnOnce(
|
||||||
&'a mut Request<Body>,
|
&'a mut Request<Body>,
|
||||||
) -> BoxFuture<
|
) -> BoxFuture<
|
||||||
'a,
|
'a,
|
||||||
Result<Result<DynMiddlewareStage2<'b, 'c, Params>, Response<Body>>, HttpError>,
|
Result<Result<DynMiddlewareStage2<Params>, Response<Body>>, HttpError>,
|
||||||
> + Send
|
> + Send
|
||||||
+ Sync,
|
+ Sync,
|
||||||
>;
|
>;
|
||||||
pub type DynMiddlewareStage2<'a, 'b, Params> = Box<
|
pub type DynMiddlewareStage2<Params> = Box<
|
||||||
dyn FnOnce(
|
dyn for<'a> FnOnce(
|
||||||
&'a mut RpcRequest<GenericRpcMethod<String, Params>>,
|
&'a mut RpcRequest<GenericRpcMethod<String, Params>>,
|
||||||
)
|
) -> BoxFuture<
|
||||||
-> BoxFuture<'a, Result<Result<DynMiddlewareStage3<'b>, Response<Body>>, HttpError>>
|
'a,
|
||||||
|
Result<Result<DynMiddlewareStage3, Response<Body>>, HttpError>,
|
||||||
|
> + Send
|
||||||
|
+ Sync,
|
||||||
|
>;
|
||||||
|
pub type DynMiddlewareStage3 = Box<
|
||||||
|
dyn for<'a> FnOnce(&'a mut Response<Body>) -> BoxFuture<'a, Result<(), HttpError>>
|
||||||
+ Send
|
+ Send
|
||||||
+ Sync,
|
+ Sync,
|
||||||
>;
|
>;
|
||||||
pub type DynMiddlewareStage3<'a> =
|
|
||||||
Box<dyn FnOnce(&'a mut Response<Body>) -> BoxFuture<'a, Result<(), HttpError>> + Send + Sync>;
|
|
||||||
|
|
||||||
pub fn constrain_middleware<
|
pub fn constrain_middleware<
|
||||||
'a,
|
'a,
|
||||||
|
|||||||
@@ -89,9 +89,9 @@ fn dothething2<U: Serialize + for<'a> Deserialize<'a> + FromStr<Err = E>, E: Dis
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn cors<'a, 'b, Params: for<'de> Deserialize<'de> + 'static>(
|
async fn cors<Params: for<'de> Deserialize<'de> + 'static>(
|
||||||
req: &mut Request<Body>,
|
req: &mut Request<Body>,
|
||||||
) -> Result<Result<DynMiddlewareStage2<'a, 'b, Params>, Response<Body>>, HttpError> {
|
) -> Result<Result<DynMiddlewareStage2<Params>, Response<Body>>, HttpError> {
|
||||||
if req.method() == hyper::Method::OPTIONS {
|
if req.method() == hyper::Method::OPTIONS {
|
||||||
Ok(Err(Response::builder()
|
Ok(Err(Response::builder()
|
||||||
.header("Access-Control-Allow-Origin", "*")
|
.header("Access-Control-Allow-Origin", "*")
|
||||||
|
|||||||
Reference in New Issue
Block a user