Skip to content

Commit c410cb5

Browse files
authored
Move to netlify_lambda_http crate
* Move to netlify_lambda_http crate - Refer issue awslabs/aws-lambda-rust-runtime#274 * Update Cargo.toml and README * Update Cargo.toml * Update README.md * Fix examples/lambda_request_context * Update Cargo.toml
1 parent b7c2cf3 commit c410cb5

File tree

4 files changed

+31
-17
lines changed

4 files changed

+31
-17
lines changed

Cargo.toml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
11
[package]
22
name = "warp_lambda"
3+
description = "A super simple crate to let you use [warp filters](https://github.com/seanmonstar/warp) with [aws lambda runtime](https://github.com/awslabs/aws-lambda-rust-runtime)"
4+
license = "MIT"
5+
readme = "README.md"
6+
repository = "https://github.com/aslamplr/warp_lambda"
7+
homepage = "https://github.com/aslamplr/warp_lambda#warp_lambda"
38
version = "0.1.0"
49
authors = ["Aslam Ahammed <[email protected]>"]
510
edition = "2018"
11+
keywords = ["lambda", "aws-lambda", "warp", "serverless", "warp-lambda"]
12+
categories = ["web-programming", "web-programming::http-server"]
613

7-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
14+
[badges]
15+
maintenance = { status = "experimental" }
816

917
[dependencies]
10-
lambda_http = { git = "https://github.com/awslabs/aws-lambda-rust-runtime.git", rev = "c36409c5e65f994c7ff48510cd111905b4aa77c9" }
11-
warp = "0.2.5"
12-
tower = "0.3.1"
13-
thiserror = "1.0.21"
18+
aws_lambda_events = "0.4"
19+
# Reference issue https://github.com/awslabs/aws-lambda-rust-runtime/issues/274
20+
# for the reason to move away from official awslabs/aws-lambda-rust-runtime
21+
# in favor of using netlify's fork lamedh-dev/aws-lambda-rust-runtime
22+
netlify_lambda_http = "0.2"
23+
warp = "0.3"
24+
tower = "0.4"
25+
thiserror = "1.0"
1426

1527
[dev-dependencies]
16-
anyhow = "1.0.33"
17-
tokio = { version = "0.2", features = [ "full" ]}
28+
anyhow = "1.0"
29+
tokio = { version = "1.2", features = [ "full" ]}

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22

33
A super simple crate to let you use [warp filters](https://github.com/seanmonstar/warp) with [aws lambda runtime](https://github.com/awslabs/aws-lambda-rust-runtime)
44

5+
> Note: Using fork of [awslabs/aws-lambda-rust-runtime](https://github.com/awslabs/aws-lambda-rust-runtime) by Netlify devs [lamedh-dev/aws-lambda-rust-runtime](https://github.com/lamedh-dev/aws-lambda-rust-runtime)
6+
> Due to issue [#216](https://github.com/awslabs/aws-lambda-rust-runtime/issues/216) and an alternative from Netlify devs [#274](https://github.com/awslabs/aws-lambda-rust-runtime/issues/274)
7+
58
> `Warning: This is experimental and not production ready! uses non stable version of aws_lambda_rust_runtime`
69
710
# Example
811

912
Add `warp_lambda`, `warp` and `tokio` to your dependencies:
1013

11-
> Note: Planning to publish `warp_lambda` crate to crates.io soon once the latest changes to aws-lambda-rust-runtime is released. Then the git dependencies won't be necessary.
12-
1314
```toml
14-
tokio = { version = "0.2", features = [ "full" ]}
15-
warp = "0.2"
16-
warp_lambda = { git = "https://github.com/aslamplr/warp_lambda.git", rev = "4eab5db86da49dcca1f5515a8173765acfcaee0a" }
15+
tokio = { version = "1.2.0", features = [ "full" ]}
16+
warp = "0.3"
17+
warp_lambda = "0.1"
1718
```
1819

1920
And then get started in your `main.rs`:

examples/lambda_request_context/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ async fn main() -> Result<()> {
1818
// Request context when invoked from an ALB event
1919
RequestContext::Alb(alb) => format!("::ALB:: {:?}", alb),
2020
// Request context when invoked from an API Gateway REST event
21-
RequestContext::ApiGateway(api_gw) => format!("::API_GW:: {:?}", api_gw),
21+
RequestContext::ApiGatewayV1(api_gw) => format!("::API_GW:: {:?}", api_gw),
2222
// Request context when invoked from an API Gateway HTTP event
2323
RequestContext::ApiGatewayV2(api_gw2) => format!("::API_GW(V2):: {:?}", api_gw2),
2424
};

src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ use core::future::Future;
22
use std::convert::Infallible;
33
use std::pin::Pin;
44

5-
pub use lambda_http;
5+
pub use netlify_lambda_http as lambda_http;
66
pub use warp;
77

8-
use lambda_http::{
8+
use aws_lambda_events::encodings::Body as LambdaBody;
9+
use netlify_lambda_http::{
910
handler,
1011
lambda::{self, Context},
11-
Body as LambdaBody, Handler, Request, Response,
12+
Handler, Request, Response,
1213
};
1314
use warp::hyper::Body as WarpBody;
1415

@@ -45,7 +46,7 @@ impl<F> Handler for WarpHandler<F>
4546
where
4647
F: tower::Service<WarpRequest, Response = WarpResponse, Error = Infallible> + 'static,
4748
{
48-
type Response = Response<lambda_http::Body>;
49+
type Response = Response<LambdaBody>;
4950
type Error = Error;
5051
type Fut = WarpHandlerFuture<Self::Response, Self::Error>;
5152

0 commit comments

Comments
 (0)