Add CORS support for servlet based impl with REST binding
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1341952 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
98c732a3f4
commit
c918a7b508
3 changed files with 9 additions and 0 deletions
|
@ -39,6 +39,7 @@ import org.apache.tuscany.sca.common.http.HTTPCacheContext;
|
|||
import org.apache.tuscany.sca.common.http.HTTPContentTypeMapper;
|
||||
import org.apache.tuscany.sca.common.http.HTTPContext;
|
||||
import org.apache.tuscany.sca.common.http.HTTPHeader;
|
||||
import org.apache.tuscany.sca.common.http.cors.CORSHeaderProcessor;
|
||||
import org.apache.tuscany.sca.invocation.Invoker;
|
||||
import org.apache.tuscany.sca.invocation.Message;
|
||||
import org.apache.tuscany.sca.invocation.MessageFactory;
|
||||
|
@ -78,6 +79,9 @@ public class RESTBindingListenerServlet extends HttpServlet {
|
|||
|
||||
@Override
|
||||
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
if (binding.isCORS()) {
|
||||
CORSHeaderProcessor.processCORS(binding.getCORSConfiguration(), request, response);
|
||||
}
|
||||
if( binding.getOperationSelector() != null || binding.getRequestWireFormat() != null) {
|
||||
HTTPContext bindingContext = new HTTPContext();
|
||||
bindingContext.setHttpRequest(request);
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.apache.tuscany.sca.binding.rest.RESTBinding;
|
|||
import org.apache.tuscany.sca.common.http.HTTPCacheContext;
|
||||
import org.apache.tuscany.sca.common.http.HTTPContext;
|
||||
import org.apache.tuscany.sca.common.http.HTTPHeader;
|
||||
import org.apache.tuscany.sca.common.http.cors.CORSHeaderProcessor;
|
||||
import org.apache.tuscany.sca.invocation.Invoker;
|
||||
import org.apache.tuscany.sca.invocation.Message;
|
||||
import org.apache.tuscany.sca.invocation.MessageFactory;
|
||||
|
@ -82,6 +83,9 @@ public class RESTServiceListenerServlet extends HttpServlet implements Servlet {
|
|||
|
||||
@Override
|
||||
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
if (binding.isCORS()) {
|
||||
CORSHeaderProcessor.processCORS(binding.getCORSConfiguration(), request, response);
|
||||
}
|
||||
HTTPContext bindingContext = new HTTPContext();
|
||||
bindingContext.setHttpRequest(request);
|
||||
bindingContext.setHttpResponse(response);
|
||||
|
|
|
@ -205,6 +205,7 @@ public class RESTBindingProcessor extends BaseStAXArtifactProcessor implements S
|
|||
restBinding.setResponseWireFormat((WireFormat)extension);
|
||||
} else if(extension instanceof OperationSelector) {
|
||||
restBinding.setOperationSelector((OperationSelector)extension);
|
||||
restBinding.setCORS(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue