Proposal for Support CORS (Cross-Origin Resource Sharing) #216#961
Proposal for Support CORS (Cross-Origin Resource Sharing) #216#961thboileau merged 12 commits intorestlet:masterfrom
Conversation
|
Thanks Manuel. To move forward with this contribution, we need to take into account those aspects:
|
|
I'v added headers mapping and fix GWT edition. You can review the PR. |
|
Manuel, it looks pretty good! Just one last change before pulling this: could you replace HeaderName by a simple String for simplification purpose? |
There was a problem hiding this comment.
file removed (use simple String)
There was a problem hiding this comment.
Typically, different resources are going to support different methods (e.g. resource A might support GET/PUT, while resource B might support GET/POST). Therefore, configuring the filter with a single standard set of allowed methods doesn't seem useful to me. Instead, I suggest that you have a default behavior of allowing all methods implemented on a given resource (those annotated with @get, @put, etc), as well as a way for developers to override that on a per-request, per-resource basis. Therefore I suggest you use response.getAllowedMethods(). By default, this will be populated to reflect the annotated methods on the ServerResource, when ServerResource.options() calls updateAllowedMethods(), but a given ServerResource can modifiy that set of methods if desired in its @Options-annotated method.
Comments from @adennie taken into account - get allowed methods from the server resource. Add CorsService.
|
All comments taken in account. |
Add a Filter to handle multiple resources and a Helper to add CORS headers manually.