We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In an Application with the netty runtime the following test passes:
Application
netty
package com.example import io.micronaut.context.annotation.Property import io.micronaut.context.annotation.Requires import io.micronaut.http.HttpRequest import io.micronaut.http.HttpResponse import io.micronaut.http.HttpStatus import io.micronaut.http.MediaType import io.micronaut.http.annotation.Controller import io.micronaut.http.annotation.Get import io.micronaut.http.annotation.Status import io.micronaut.http.client.HttpClient import io.micronaut.http.client.annotation.Client import io.micronaut.test.extensions.spock.annotation.MicronautTest import jakarta.inject.Inject import spock.lang.Specification @Property(name = 'spec.name', value = 'ContentTypeSpec') @MicronautTest class ContentTypeSpec extends Specification { @Inject @Client("/") HttpClient httpClient void "verify controllers return json by default"() { given: HttpRequest<?> request = HttpRequest._GET_('/json/bydefault').accept(MediaType.APPLICATION_JSON) when: HttpResponse<String> response = httpClient.toBlocking().exchange(request, String) then: HttpStatus._OK_ == response.status() response.body.get() == '{"msg":"Hello world"}' response.headers "application/json" == response.headers.get("Content-Type") } @Controller('/json') @Requires(property = 'spec.name', value = 'ContentTypeSpec') static class BodyController { @Get("/bydefault") @Status(HttpStatus.OK) Map<String, Object> index() { [msg: "Hello world"] } } }
However, an Application with lambda runtime the following tests fails:
lambda
package com.example import com.amazonaws.serverless.proxy.internal.testutils.AwsProxyRequestBuilder import com.amazonaws.serverless.proxy.internal.testutils.MockLambdaContext import com.amazonaws.serverless.proxy.model.AwsProxyRequest import com.amazonaws.serverless.proxy.model.AwsProxyResponse import com.amazonaws.services.lambda.runtime.Context import io.micronaut.function.aws.proxy.MicronautLambdaHandler import io.micronaut.http.HttpHeaders import io.micronaut.http.HttpMethod import io.micronaut.http.HttpStatus import io.micronaut.http.MediaType import io.micronaut.http.annotation.Controller import io.micronaut.http.annotation.Get import io.micronaut.http.annotation.Status import spock.lang.AutoCleanup import spock.lang.Shared import spock.lang.Specification class ContentTypeWithoutMicronautTestSpec extends Specification { @Shared @AutoCleanup MicronautLambdaHandler handler = new MicronautLambdaHandler() @Shared Context lambdaContext = new MockLambdaContext() void "verify controllers return json by default"() { given: AwsProxyRequest request = new AwsProxyRequestBuilder("/json/isthedefault", HttpMethod.GET.toString()) .header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON) .build() when: AwsProxyResponse response = handler.handleRequest(request, lambdaContext) then: HttpStatus._OK_.code == response.statusCode response.body == '{"msg":"Hello world"}' response.headers "application/json" == response.headers.get("Content-Type") } @Controller('/json') static class JsonIsTheDefaultController { @Get("/isthedefault") @Status(HttpStatus._OK_) Map<String, Object> index() { [msg: "Hello world"] } } }
With headers being null in the response.
headers
The text was updated successfully, but these errors were encountered:
add failing test
0fb4683
Fixes: #1330
fix: Populate AWSProxyResponse headers with multi
47cfaa4
Successfully merging a pull request may close this issue.
In an
Application
with thenetty
runtime the following test passes:However, an
Application
withlambda
runtime the following tests fails:With
headers
being null in the response.The text was updated successfully, but these errors were encountered: