Skip to content

Commit 6586fd3

Browse files
committed
Merge branch 'main' into support-utf-8-in-header-value
2 parents 8da501e + 9f8f250 commit 6586fd3

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

.github/workflows/closed-issue-message.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,5 @@ jobs:
1111
# These inputs are both required
1212
repo-token: "${{ secrets.GITHUB_TOKEN }}"
1313
message: |
14-
### ⚠️COMMENT VISIBILITY WARNING⚠️
15-
Comments on closed issues are hard for the maintainers of this repository to see.
16-
If you need more assistance, please open a new issue that references this one.
17-
If you wish to keep having a conversation with other community members under this issue feel free to do so.
14+
This issue is now closed. Comments on closed issues are hard for our team to see.
15+
If you need more assistance, please either tag a team member or open a new issue that references this one.

examples/http-axum/src/main.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
//! implementation to the Lambda runtime to run as a Lambda function. By using Axum instead
77
//! of a basic `tower::Service` you get web framework niceties like routing, request component
88
//! extraction, validation, etc.
9-
9+
use std::env::set_var;
10+
use axum::http::StatusCode;
1011
use lambda_http::{
1112
run,
1213
Error,
@@ -35,8 +36,22 @@ async fn post_foo_name(Path(name): Path<String>) -> Json<Value> {
3536
Json(json!({ "msg": format!("I am POST /foo/:name, name={name}") }))
3637
}
3738

39+
/// Example on how to return status codes and data from a Axum function
40+
async fn health_check() -> (StatusCode, &str) {
41+
let healthy = false;
42+
match health {
43+
true => {(StatusCode::OK, "Healthy!")},
44+
false => {(StatusCode::INTERNAL_SERVER_ERROR, "Not healthy!")}
45+
}
46+
}
47+
3848
#[tokio::main]
3949
async fn main() -> Result<(), Error> {
50+
// AWS Runtime can ignore Stage Name passed from json event
51+
// Remove if you want the first section of the url to be the stage name of the API Gateway
52+
// i.e with: `GET /test-stage/todo/id/123` without: `GET /todo/id/123`
53+
set_var("AWS_LAMBDA_HTTP_IGNORE_STAGE_IN_PATH", "true");
54+
4055
// required to enable CloudWatch error logging by the runtime
4156
tracing_subscriber::fmt()
4257
.with_max_level(tracing::Level::INFO)
@@ -49,7 +64,8 @@ async fn main() -> Result<(), Error> {
4964
let app = Router::new()
5065
.route("/", get(root))
5166
.route("/foo", get(get_foo).post(post_foo))
52-
.route("/foo/:name", post(post_foo_name));
67+
.route("/foo/:name", post(post_foo_name))
68+
.route("/health/", get(health_check));
5369

5470
run(app).await
5571
}

0 commit comments

Comments
 (0)