Spring Boot 2: StageName should be stripped from the path by default
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- aws, java, spring-boot
Hướng nghiên cứu
Bắt đầu với LambdaHandler và cấu hình SpringBootProxyHandlerBuilder của nó, sau đó so sánh SAM HttpApi StageName và đường dẫn proxy được hiển thị trong issue với đường dẫn request mà Spring Boot nhận được. Kiểm tra cách handler.stripBasePath được sử dụng và mặc định không cần tên stage; hoàn thành khi các request như /dev/api/v1/some/resource được định tuyến thành /api/v1/some/resource mà không gặp 404.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Serverless Java Container version: 1.5.2
Implementations: Spring Boot 2
Framework version: spring-boot-starter-parent 2.3.8.RELEASE
Frontend service: AWS::Serverless::HttpApi (API Gateway HTTP)
Deployment method: SAM CLI
Scenario
Configure a simple HTTP API proxy to Lambda using Spring Boot 2, and be able to route requests that ignore the stage-name.
Expected behavior
Stage name (which is part of the path by default) is stripped before spring routes/maps to a controller.
Actual behavior
Getting 404's b/c spring is mapping <stage>/<path> vs <path>; requires my code to be 'stage-name aware'.
Steps to reproduce
event-source in sam template for AWS::Serverless::Function
Events:
BaseAdmin:
Type: HttpApi
Properties:
ApiId: !Ref Api
Method: any
Path: /{proxy+}
PayloadFormatVersion: "1.0"
RouteSettings:
ThrottlingBurstLimit: 100
ThrottlingRateLimit: 100
TimeoutInMillis: 29000
api def in sam template:
Api:
Type: AWS::Serverless::HttpApi
Properties:
FailOnWarnings: true
StageName: dev
lambda handler
public class LambdaHandler implements RequestStreamHandler {
private static final SpringBootLambdaContainerHandler<AwsProxyRequest, AwsProxyResponse> HANDLER;
static {
Application.envSetup();
try {
HANDLER = new SpringBootProxyHandlerBuilder<AwsProxyRequest>().defaultProxy()
.asyncInit()
.springBootApplication(Application.class)
.buildAndInitialize();
} catch (ContainerInitializationException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
// Want to not need the line below uncommented to work!
// HANDLER.stripBasePath(System.getenv("STRIP_BASE_PATH"));
}
@Override
public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context) throws IOException {
HANDLER.proxyStream(inputStream, outputStream, context);
}
}
Full log output
Paste the full log output from the Lambda function's CloudWatch logs
dev is the stage name; the mapping is for /api/v1
DEBUG DispatcherServlet - GET "/dev/api/v1/some/resource", parameters={}
DEBUG DispatcherServlet - Exiting from "ERROR" dispatch, status 404
This isn't the worst thing ever...but it's definitely counter-intuitive to me. Would also appreciate any feedback on my solution; I did try some of the config options mentioned on the wiki page, but none of them seemed to do the trick until i found handler.stripBasePath. If there is a way to do this w/o passing in the StageName, that'd be better. Having it work by default would obviously be best.
- Ngôn ngữ chính
- Java
- Star
- 1.6k
- Fork
- 575
- Merge trung bình
- 1 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 12
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của aws/serverless-java-container
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
aws/serverless-java-container#1729 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
aws/serverless-java-container#1715 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Support for API Gateway mTLS clientCert fieldCó thể đã có người làm @2748109647 đã nhận 10 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 48/100
aws/serverless-java-container#1726 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
aws/serverless-java-container#1579 · 3 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 42/100
aws/serverless-java-container#1568 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của aws/serverless-java-container
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
ls1intum/thesis-management#1473 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
LunaDeerMC/Dominion#301 · 1 bình luận ·
-
[FEATURE] Expose external refresh, node-level translog and warmer statsCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởuntriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
opensearch-project/opensearch-prometheus-exporter#680 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100