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

Aberta
#1,435 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
30/100
Tipo de issue
Bug
Clareza
Precisa de esclarecimento
Status de atividade
Estagnada
Stack de tecnologia
aws, java, spring-boot
Domínio
api, backend, cloud

Direção de pesquisa

Comece pelo exemplo vinculado de StreamLambdaHandler.java e inspecione a configuração de conteúdo binário do contêiner serverless para respostas da AWS. Reproduza o problema com springdoc-openapi-starter-webmvc-ui e, em seguida, determine se application/javascript e text/css devem ser reconhecidos por padrão; considera-se concluído quando os assets do Swagger UI são carregados por meio do API Gateway e há cobertura para o comportamento de resposta esperado.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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

Linguagem predominante
Java
Estrelas
1.6k
Forks
575
Merge médio
1d 15h
PRs com merge (30d)
12

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de aws/serverless-java-container

Todas as issues de aws/serverless-java-container

Issues semelhantes

Mais issues de Java

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.