-
Notifications
You must be signed in to change notification settings - Fork 550
New issue
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
@QueryParam and @Context HttpServletRequest context is not working properly. #228
Comments
Are you running in SAM local? Could you log the event? The framework depends on the multiValueHeaders and query string parameter fields, are those present in the SAM local event? |
Hi Stefano, Many thanks for the comment. Yes you are correct. I am using SAM Local for this. I just downloaded jersey pet store code from https://github.com/awslabs/aws-serverless-java-container/tree/master/samples/jersey/pet-store and following the steps mentioned in the https://aws.amazon.com/blogs/opensource/java-apis-aws-lambda/ blog. I am not sure about the event as I am using "sam local start-api --template sam.yaml" to start the server. Then using the curl command to send the request to the API. The curl command I am using is "curl -s http://127.0.0.1:3000/pets?limit=1" So, are you suggesting that there are some other configuration in the SAM Local, which I need to look. |
Hi Stefano, below are code files for the reference:
import org.glassfish.jersey.internal.inject.AbstractBinder; import java.io.IOException; import javax.servlet.ServletContext; @SuppressWarnings("unused")
}
package my.service; import my.service.resource.Pet; import javax.inject.Inject; import java.util.Map; @path("/pets")
}
AWSTemplateFormatVersion: '2010-09-09' Globals: Resources: Outputs:
|
Just check on the SAM local repo - looks like this is indeed not supported yet in SAM local. I will try to contribute the fix for them. |
Checking in with @jfuss on whether they have an issue tracking |
The new release of the SAM CLI supports the multi-value fields. You can install it from the repo's head: |
Scenario: I have downloaded the sample code for jersey pet store project. Completed the maven build and tired to test using AWS SAM Local. I was able to publish the sample pet store project on AWS SAM Local. However when, i use curl -s http://127.0.0.1:3000/pets?limit=1 from terminal in AWS SAM Local environment, the value of "limit" is not available in the public Pet[] listPets(@QueryParam("limit") int limit) method of the PetsResource.java class. Also, getParameterNames() method of the HttpServletRequest is not returning parameter names when used in AWS SAM Local environment. The same is happening for spring pet store as well.
Expected behavior: when curl -s http://127.0.0.1:3000/pets?limit=1 is used, it should show only 1 record.
Also, the getParameterNames() method of the HttpServletRequest should return "limit" as parameter in PetsResource.java class when curl -s http://127.0.0.1:3000/pets?limit=1 is used.
Actual behavior : It is displaying 10 records as below.
[{"id":"c33b4204-7bc0-4c46-b69d-4cc46d62bf69","breed":"Jack Russell Terrier","name":"Bear","dateOfBirth":1133369382990},{"id":"cd774218-8150-420c-abf7-7826d9656097","breed":"Jack Russell Terrier","name":"Abby","dateOfBirth":1282063782990},{"id":"f5eb57fc-ca0b-4ee8-9616-bc30faf7a70b","breed":"Jack Russell Terrier","name":"Chloe","dateOfBirth":1389026982990},{"id":"24d84825-e897-45e7-829d-5f69ce8b0117","breed":"Jack Russell Terrier","name":"Jack","dateOfBirth":1265215782990},{"id":"63c876f5-a96f-4112-bd7c-8d3aa3e27f99","breed":"Dalmatian","name":"Gracie","dateOfBirth":1122742182990},{"id":"766bbd96-fe25-4f8c-aa04-d6795f617064","breed":"Jack Russell Terrier","name":"Bella","dateOfBirth":1091551782991},{"id":"fcf42666-c8e2-4e93-8674-c83994c6d16e","breed":"Dalmatian","name":"Sasha","dateOfBirth":1160844582991},{"id":"49d4955b-5994-48e0-be30-f64796016ea6","breed":"Jack Russell Terrier","name":"Lola","dateOfBirth":1161622182991},{"id":"99c37613-ed60-49a6-8cef-1efb6acec93d","breed":"Dalmatian","name":"Bella","dateOfBirth":1530722982991},{"id":"be3231a2-dfa8-4f26-9df6-7cfb067383be","breed":"Bernese Mountain Dog","name":"Bear","dateOfBirth":1166633382991}]my_machine:my-spring-service user1$
Also, getParameterNames() method of the HttpServletRequest is returning null.
Steps to reproduce
Full log output
The text was updated successfully, but these errors were encountered: