camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/2] camel git commit: CAMEL-9761: Use constant for default CORS headers.
Date Fri, 25 Mar 2016 16:16:02 GMT
CAMEL-9761: Use constant for default CORS headers.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9d3ff74b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9d3ff74b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9d3ff74b

Branch: refs/heads/camel-2.17.x
Commit: 9d3ff74ba877eb20bcae87e7d72fad8b7e4a85b2
Parents: e9bb6ba
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri Mar 25 16:05:40 2016 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Mar 25 17:15:54 2016 +0100

----------------------------------------------------------------------
 .../org/apache/camel/swagger/RestSwaggerSupport.java | 15 +++++++++------
 .../camel/swagger/servlet/RestSwaggerCorsFilter.java | 10 ++++++----
 2 files changed, 15 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/9d3ff74b/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/RestSwaggerSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/RestSwaggerSupport.java
b/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/RestSwaggerSupport.java
index 24f4164..a275a0e 100644
--- a/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/RestSwaggerSupport.java
+++ b/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/RestSwaggerSupport.java
@@ -42,6 +42,7 @@ import org.apache.camel.model.ModelHelper;
 import org.apache.camel.model.rest.RestDefinition;
 import org.apache.camel.model.rest.RestsDefinition;
 import org.apache.camel.spi.ClassResolver;
+import org.apache.camel.spi.RestConfiguration;
 import org.apache.camel.util.CamelVersionHelper;
 import org.apache.camel.util.EndpointHelper;
 import org.slf4j.Logger;
@@ -194,9 +195,10 @@ public class RestSwaggerSupport {
         LOG.trace("renderResourceListing");
 
         if (cors) {
-            response.setHeader("Access-Control-Allow-Headers", "Origin, Accept, X-Requested-With,
Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers");
-            response.setHeader("Access-Control-Allow-Methods", "GET, HEAD, POST, PUT, DELETE,
TRACE, OPTIONS, CONNECT, PATCH");
-            response.setHeader("Access-Control-Allow-Origin", "*");
+            response.setHeader("Access-Control-Allow-Origin", RestConfiguration.CORS_ACCESS_CONTROL_ALLOW_ORIGIN);
+            response.setHeader("Access-Control-Allow-Methods", RestConfiguration.CORS_ACCESS_CONTROL_ALLOW_METHODS);
+            response.setHeader("Access-Control-Allow-Headers", RestConfiguration.CORS_ACCESS_CONTROL_ALLOW_HEADERS);
+            response.setHeader("Access-Control-Max-Age", RestConfiguration.CORS_ACCESS_CONTROL_MAX_AGE);
         }
 
         List<RestDefinition> rests = getRestDefinitions(contextId);
@@ -248,9 +250,10 @@ public class RestSwaggerSupport {
         LOG.trace("renderCamelContexts");
 
         if (cors) {
-            response.setHeader("Access-Control-Allow-Headers", "Origin, Accept, X-Requested-With,
Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers");
-            response.setHeader("Access-Control-Allow-Methods", "GET, HEAD, POST, PUT, DELETE,
TRACE, OPTIONS, CONNECT, PATCH");
-            response.setHeader("Access-Control-Allow-Origin", "*");
+            response.setHeader("Access-Control-Allow-Origin", RestConfiguration.CORS_ACCESS_CONTROL_ALLOW_ORIGIN);
+            response.setHeader("Access-Control-Allow-Methods", RestConfiguration.CORS_ACCESS_CONTROL_ALLOW_METHODS);
+            response.setHeader("Access-Control-Allow-Headers", RestConfiguration.CORS_ACCESS_CONTROL_ALLOW_HEADERS);
+            response.setHeader("Access-Control-Max-Age", RestConfiguration.CORS_ACCESS_CONTROL_MAX_AGE);
         }
 
         List<String> contexts = findCamelContexts();

http://git-wip-us.apache.org/repos/asf/camel/blob/9d3ff74b/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/servlet/RestSwaggerCorsFilter.java
----------------------------------------------------------------------
diff --git a/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/servlet/RestSwaggerCorsFilter.java
b/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/servlet/RestSwaggerCorsFilter.java
index 4aca487..3570fe6 100644
--- a/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/servlet/RestSwaggerCorsFilter.java
+++ b/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/servlet/RestSwaggerCorsFilter.java
@@ -25,6 +25,8 @@ import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.camel.spi.RestConfiguration;
+
 /**
  * A simple CORS filter that can used to allow the swagger ui or other API browsers from
remote origins to access the
  * Rest services exposes by this Camel swagger component.
@@ -45,10 +47,10 @@ public class RestSwaggerCorsFilter implements Filter {
     public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
         HttpServletResponse res = (HttpServletResponse) response;
 
-        res.setHeader("Access-Control-Allow-Origin", "*");
-        res.setHeader("Access-Control-Allow-Methods", "GET, HEAD, POST, PUT, DELETE, TRACE,
OPTIONS, CONNECT, PATCH");
-        res.setHeader("Access-Control-Max-Age", "3600");
-        res.setHeader("Access-Control-Allow-Headers", "Origin, Accept, X-Requested-With,
Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers");
+        res.setHeader("Access-Control-Allow-Origin", RestConfiguration.CORS_ACCESS_CONTROL_ALLOW_ORIGIN);
+        res.setHeader("Access-Control-Allow-Methods", RestConfiguration.CORS_ACCESS_CONTROL_ALLOW_METHODS);
+        res.setHeader("Access-Control-Allow-Headers", RestConfiguration.CORS_ACCESS_CONTROL_ALLOW_HEADERS);
+        res.setHeader("Access-Control-Max-Age", RestConfiguration.CORS_ACCESS_CONTROL_MAX_AGE);
 
         chain.doFilter(request, response);
     }


Mime
View raw message