hanabu / lambda-web

Run Rust web frameworks on AWS Lambda
MIT License
115 stars 38 forks source link

Using demo app, I get a 404 #7

Open bennichols opened 2 years ago

bennichols commented 2 years ago

Hi, I'm trying to get the example application working with axum (0.3.4, although I've tried with the latest as well). I'm use CodeBuild using the same buildspec.yml file recommended, and everything seems to be building correctly. I push the build to the lambda and then create the API Gateway HTTP proxy as recommended. When I try to hit the generated endpoint, the response is:

{"message":"Not Found"}

API Gateway Logs:

START RequestId: f2682bf7-17cd-4cc6-aa0d-e9f192a991b7 Version: $LATEST
2022-01-04T04:38:51.734927Z DEBUG musofile_api: start!
2022-01-04T04:38:51.739864Z DEBUG musofile_api: running on lambda!
2022-01-04T04:38:51.743546Z DEBUG hyper::client::connect::http: connecting to 127.0.0.1:9001
2022-01-04T04:38:51.745134Z DEBUG hyper::client::connect::http: connected to 127.0.0.1:9001
2022-01-04T04:38:51.745407Z DEBUG hyper::proto::h1::io: flushed 74 bytes
2022-01-04T04:38:51.747265Z DEBUG hyper::proto::h1::io: parsed 7 headers
2022-01-04T04:38:51.747291Z DEBUG hyper::proto::h1::conn: incoming body is chunked encoding
2022-01-04T04:38:51.747350Z DEBUG hyper::proto::h1::decode: incoming chunked header: 0x9CD (2509 bytes)
2022-01-04T04:38:51.747424Z DEBUG hyper::proto::h1::conn: incoming body completed
2022-01-04T04:38:51.747492Z DEBUG hyper::client::pool: pooling idle connection for ("http", 127.0.0.1:9001)
2022-01-04T04:38:51.748952Z DEBUG request{method=GET uri=https://localhost/?foo=bar version=HTTP/1.1}: tower_http::trace::on_request: started processing request
2022-01-04T04:38:51.748976Z DEBUG request{method=GET uri=https://localhost/?foo=bar version=HTTP/1.1}: musofile_api: root!
2022-01-04T04:38:51.748986Z DEBUG request{method=GET uri=https://localhost/?foo=bar version=HTTP/1.1}: tower_http::trace::on_response: finished processing request latency=0 ms status=200
2022-01-04T04:38:51.749018Z DEBUG hyper::client::pool: reuse idle connection for ("http", 127.0.0.1:9001)
2022-01-04T04:38:51.749085Z DEBUG hyper::proto::h1::io: flushed 260 bytes
2022-01-04T04:38:51.757924Z DEBUG hyper::proto::h1::io: parsed 3 headers
2022-01-04T04:38:51.757964Z DEBUG hyper::proto::h1::conn: incoming body is content-length (16 bytes)
2022-01-04T04:38:51.757978Z DEBUG hyper::proto::h1::conn: incoming body completed
2022-01-04T04:38:51.758008Z DEBUG hyper::client::pool: pooling idle connection for ("http", 127.0.0.1:9001)
2022-01-04T04:38:51.777303Z DEBUG hyper::client::pool: reuse idle connection for ("http", 127.0.0.1:9001)
2022-01-04T04:38:51.777475Z DEBUG hyper::proto::h1::io: flushed 74 bytes
END RequestId: f2682bf7-17cd-4cc6-aa0d-e9f192a991b7
REPORT RequestId: f2682bf7-17cd-4cc6-aa0d-e9f192a991b7  Duration: 30.98 ms  Billed Duration: 90 ms  Memory Size: 128 MB Max Memory Used: 22 MB  Init Duration: 58.53 ms

Interestingly, if I use the Test functionality in the lambda, it seems like the code is flowing correctly:

START RequestId: f2682bf7-17cd-4cc6-aa0d-e9f192a991b7 Version: $LATEST
2022-01-04T04:38:51.734927Z DEBUG musofile_api: start!
2022-01-04T04:38:51.739864Z DEBUG musofile_api: running on lambda!
2022-01-04T04:38:51.743546Z DEBUG hyper::client::connect::http: connecting to 127.0.0.1:9001
2022-01-04T04:38:51.745134Z DEBUG hyper::client::connect::http: connected to 127.0.0.1:9001
2022-01-04T04:38:51.745407Z DEBUG hyper::proto::h1::io: flushed 74 bytes
2022-01-04T04:38:51.747265Z DEBUG hyper::proto::h1::io: parsed 7 headers
2022-01-04T04:38:51.747291Z DEBUG hyper::proto::h1::conn: incoming body is chunked encoding
2022-01-04T04:38:51.747350Z DEBUG hyper::proto::h1::decode: incoming chunked header: 0x9CD (2509 bytes)
2022-01-04T04:38:51.747424Z DEBUG hyper::proto::h1::conn: incoming body completed
2022-01-04T04:38:51.747492Z DEBUG hyper::client::pool: pooling idle connection for ("http", 127.0.0.1:9001)
2022-01-04T04:38:51.748952Z DEBUG request{method=GET uri=https://localhost/?foo=bar version=HTTP/1.1}: tower_http::trace::on_request: started processing request
2022-01-04T04:38:51.748976Z DEBUG request{method=GET uri=https://localhost/?foo=bar version=HTTP/1.1}: musofile_api: root!
2022-01-04T04:38:51.748986Z DEBUG request{method=GET uri=https://localhost/?foo=bar version=HTTP/1.1}: tower_http::trace::on_response: finished processing request latency=0 ms status=200
2022-01-04T04:38:51.749018Z DEBUG hyper::client::pool: reuse idle connection for ("http", 127.0.0.1:9001)
2022-01-04T04:38:51.749085Z DEBUG hyper::proto::h1::io: flushed 260 bytes
2022-01-04T04:38:51.757924Z DEBUG hyper::proto::h1::io: parsed 3 headers
2022-01-04T04:38:51.757964Z DEBUG hyper::proto::h1::conn: incoming body is content-length (16 bytes)
2022-01-04T04:38:51.757978Z DEBUG hyper::proto::h1::conn: incoming body completed
2022-01-04T04:38:51.758008Z DEBUG hyper::client::pool: pooling idle connection for ("http", 127.0.0.1:9001)
2022-01-04T04:38:51.777303Z DEBUG hyper::client::pool: reuse idle connection for ("http", 127.0.0.1:9001)
2022-01-04T04:38:51.777475Z DEBUG hyper::proto::h1::io: flushed 74 bytes
END RequestId: f2682bf7-17cd-4cc6-aa0d-e9f192a991b7
REPORT RequestId: f2682bf7-17cd-4cc6-aa0d-e9f192a991b7  Duration: 30.98 ms  Billed Duration: 90 ms  Memory Size: 128 MB Max Memory Used: 22 MB  Init Duration: 58.53 ms

Any ideas? I think I've followed the instructions well and have only added some logging to the code.

Thanks!

mehmetcansahin commented 2 years ago

i getting same error.

vporton commented 2 years ago

In #10 I have a similar bug, note that in #10 the bug is only for non-root paths.