From 1a3deb442cb80eed6a379d5c0a375aea019703d0 Mon Sep 17 00:00:00 2001 From: Istvan Szukacs Date: Tue, 12 Dec 2023 12:46:35 +0100 Subject: [PATCH 1/2] Updating versions and fmt --- Cargo.toml | 13 +++++++++---- src/lib.rs | 3 +-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 73adacb..3d57134 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ description = "Tower Layer for compatibility between Axum and AWS Lambda Runtime readme = "README.md" homepage = "https://github.com/lazear/axum-aws-lambda" repository = "https://github.com/lazear/axum-aws-lambda" -license ="MIT" +license = "MIT" keywords = ["axum", "lambda", "tower", "aws"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -16,14 +16,19 @@ keywords = ["axum", "lambda", "tower", "aws"] axum = "0.6" lambda_http = "0.8" hyper = "0.14" -bytes = "1" -http = "0.2" +bytes = "1.5" +http = "1" tower = "0.4" tower-service = "0.3" [dev-dependencies] tokio = { version = "1.0", features = ["rt"] } -tower-http = { version = "0.4", features = ["cors", "compression-gzip", "compression-deflate", "trace"] } +tower-http = { version = "0.4", features = [ + "cors", + "compression-gzip", + "compression-deflate", + "trace", +] } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["json"] } serde = { version = "1.0", features = ["derive"] } diff --git a/src/lib.rs b/src/lib.rs index 1167eea..5f15100 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,4 @@ use axum::response::IntoResponse; -use http::Uri; use lambda_http::RequestExt; use std::{future::Future, pin::Pin}; use tower::Layer; @@ -77,7 +76,7 @@ where url.push('?'); url.push_str(query); } - parts.uri = url.parse::().unwrap(); + parts.uri = url.parse::().unwrap(); } let request = axum::http::Request::from_parts(parts, body); From 8eb0d166a81f93cb7895bfc7fcc49de67e96a999 Mon Sep 17 00:00:00 2001 From: Istvan Szukacs Date: Tue, 12 Dec 2023 12:55:34 +0100 Subject: [PATCH 2/2] Fixing example --- examples/main.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/examples/main.rs b/examples/main.rs index be817b8..6f9bf17 100644 --- a/examples/main.rs +++ b/examples/main.rs @@ -1,11 +1,11 @@ use axum::extract::State; +use axum::http::header::{ACCEPT, ACCEPT_ENCODING, AUTHORIZATION, CONTENT_TYPE, ORIGIN}; use axum::response::IntoResponse; use axum::{ routing::{get, post}, Json, Router, }; -use http::header::{ACCEPT, ACCEPT_ENCODING, AUTHORIZATION, CONTENT_TYPE, ORIGIN}; -use http::Request; +use hyper::Request; use hyper::{Body, StatusCode}; use serde::{Deserialize, Serialize}; use std::sync::{Arc, Mutex}; @@ -54,13 +54,7 @@ async fn main() { // Set up CORS let cors_layer = CorsLayer::new() - .allow_headers(vec![ - ACCEPT, - ACCEPT_ENCODING, - AUTHORIZATION, - CONTENT_TYPE, - ORIGIN, - ]) + .allow_headers([ACCEPT, ACCEPT_ENCODING, AUTHORIZATION, CONTENT_TYPE, ORIGIN]) .allow_methods(tower_http::cors::Any) .allow_origin(tower_http::cors::Any);