Spring Boot 2: StageName should be stripped from the path by default
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- aws, java, spring-boot
Direzione di ricerca
Inizia con LambdaHandler e la relativa configurazione SpringBootProxyHandlerBuilder, quindi confronta il SAM HttpApi StageName e il percorso del proxy mostrati nell’issue con il percorso della richiesta ricevuta da Spring Boot. Verifica come viene usato handler.stripBasePath e rendi superfluo il nome dello stage per impostazione predefinita; il lavoro è completato quando richieste come /dev/api/v1/some/resource vengono instradate come /api/v1/some/resource senza un 404.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Java
- Stelle
- 1.6k
- Fork
- 575
- Merge medio
- 1g 15h
- PR unite (30g)
- 12
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di aws/serverless-java-container
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
aws/serverless-java-container#1729 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
aws/serverless-java-container#1715 ·
I maintainer di solito rispondono entro 1 giorno
-
Support for API Gateway mTLS clientCert fieldForse già presa @2748109647 l’ha presa 10 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 48/100
aws/serverless-java-container#1726 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
aws/serverless-java-container#1579 · 3 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 42/100
aws/serverless-java-container#1568 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di aws/serverless-java-container
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
ls1intum/thesis-management#1473 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
LunaDeerMC/Dominion#301 · 1 commento ·
-
[FEATURE] Expose external refresh, node-level translog and warmer statsForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertauntriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
opensearch-project/opensearch-prometheus-exporter#680 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100