diff --git a/lambda-http/src/lib.rs b/lambda-http/src/lib.rs index 1e532b0d..bfdb8f1d 100644 --- a/lambda-http/src/lib.rs +++ b/lambda-http/src/lib.rs @@ -96,7 +96,7 @@ pub trait Handler<'a>: Sized { /// The type of Future this Handler will return type Fut: Future> + 'a; /// Function used to execute handler behavior - fn call(&self, event: Request, context: Context) -> Self::Fut; + fn call(&mut self, event: Request, context: Context) -> Self::Fut; } /// Adapts a [`Handler`](trait.Handler.html) to the `lambda_runtime::run` interface @@ -117,7 +117,7 @@ where type Response = R; type Error = Error; type Fut = Fut; - fn call(&self, event: Request, context: Context) -> Self::Fut { + fn call(&mut self, event: Request, context: Context) -> Self::Fut { (self)(event, context) } } @@ -159,7 +159,7 @@ impl<'a, H: Handler<'a>> Handler<'a> for Adapter<'a, H> { type Response = H::Response; type Error = H::Error; type Fut = H::Fut; - fn call(&self, event: Request, context: Context) -> Self::Fut { + fn call(&mut self, event: Request, context: Context) -> Self::Fut { self.handler.call(event, context) } } @@ -168,7 +168,7 @@ impl<'a, H: Handler<'a>> LambdaHandler, LambdaResponse> for Ad type Error = H::Error; type Fut = TransformResponse<'a, H::Response, Self::Error>; - fn call(&self, event: LambdaRequest<'_>, context: Context) -> Self::Fut { + fn call(&mut self, event: LambdaRequest<'_>, context: Context) -> Self::Fut { let request_origin = event.request_origin(); let fut = Box::pin(self.handler.call(event.into(), context)); TransformResponse { request_origin, fut } diff --git a/lambda-runtime/src/lib.rs b/lambda-runtime/src/lib.rs index ec145dcc..d7e7f52c 100644 --- a/lambda-runtime/src/lib.rs +++ b/lambda-runtime/src/lib.rs @@ -75,7 +75,7 @@ pub trait Handler { /// Response of this handler. type Fut: Future>; /// Handle the incoming event. - fn call(&self, event: A, context: Context) -> Self::Fut; + fn call(&mut self, event: A, context: Context) -> Self::Fut; } /// Returns a new [`HandlerFn`] with the given closure. @@ -101,7 +101,7 @@ where { type Error = Error; type Fut = Fut; - fn call(&self, req: A, ctx: Context) -> Self::Fut { + fn call(&mut self, req: A, ctx: Context) -> Self::Fut { (self.f)(req, ctx) } } @@ -135,7 +135,7 @@ where pub async fn run( &self, incoming: impl Stream, Error>> + Send, - handler: F, + mut handler: F, config: &Config, ) -> Result<(), Error> where