Need to add application/javascript and text/css as binary types for

Aperta
#1,435 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

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
30/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
aws, java, spring-boot
Ambito
api, backend, cloud

Direzione di ricerca

Inizia con l’esempio collegato StreamLambdaHandler.java e analizza la configurazione dei contenuti binari del container serverless per le risposte AWS. Riproduci il problema con springdoc-openapi-starter-webmvc-ui, quindi determina se application/javascript e text/css debbano essere riconosciuti per impostazione predefinita; il lavoro è completato quando gli asset di Swagger UI vengono caricati tramite API Gateway ed è presente la copertura per il comportamento di risposta previsto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

I don't know which component in the stack is wrong.

  • springdoc-openapi-starter-webmvc-ui will serve up swagger-ui/index.html, locally 100% and when deployed to a AWS API Gateway (HTTP-style) only some .js files and the .html file serve, the rest blowing up in the API Gateway response with no error message

I think the minimal repro is to add springdoc-openapi-starter-webmvc-ui (via pom.xml) to the ping controller example (which is a bad name for an endpoint because it clashes with the automatically provided route of AWS API Gateway, I usually have to rename it to pong)

I told the container to treat application/javascript and text/css as binary and API Gateway stopped trying to do something (unnecessary encoding/decoding) to the response and now swagger-ui loads.

I'm leaving this here because other issues have run into the same problem and came up with worse workarounds (like stop even trying to serve some content types on API Gateway at all)

That this works locally in tomcat makes me think that something is wrong with API Gateway or serverless-container.

        <dependency>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
            <version>2.8.6</version>
        </dependency>
public class StreamLambdaHandler implements RequestStreamHandler, Resource {
    private static SpringBootLambdaContainerHandler<AwsProxyRequest, AwsProxyResponse> handler;
    static {
        try {
            handler = SpringBootLambdaContainerHandler.getAwsProxyHandler(Application.class);
            LambdaContainerHandler.getContainerConfig().addBinaryContentTypes("application/javascript");
            LambdaContainerHandler.getContainerConfig().addBinaryContentTypes("text/css");
        } catch (ContainerInitializationException e) {
            // if we fail here. We re-throw the exception to force another cold start
            e.printStackTrace();
            throw new RuntimeException("Could not initialize Spring Boot application", e);
        }
    }
}

My code: https://github.com/matthewdeanmartin/lambda_for_free/blob/main/spring_http/src/main/java/com/example/interviews/StreamLambdaHandler.java#L27

Lingua principale
Java
Stelle
1.6k
Fork
575
Merge medio
1g 15h
PR unite (30g)
12

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di aws/serverless-java-container

Tutte le issue di aws/serverless-java-container

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.