From 00e181c8aa5b7e75a3421872219f28f71901b56f Mon Sep 17 00:00:00 2001 From: Zellweger Christof Ralf Date: Wed, 28 Oct 2015 13:03:18 +0100 Subject: [PATCH] ATEST-259: - clean up, improving naming --- .../java/ch/psi/daq/queryrest/config/QueryRestConfig.java | 7 ++----- src/main/resources/queryrest.properties | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/main/java/ch/psi/daq/queryrest/config/QueryRestConfig.java b/src/main/java/ch/psi/daq/queryrest/config/QueryRestConfig.java index 3dc83c4..78eaf75 100644 --- a/src/main/java/ch/psi/daq/queryrest/config/QueryRestConfig.java +++ b/src/main/java/ch/psi/daq/queryrest/config/QueryRestConfig.java @@ -13,6 +13,7 @@ import javax.servlet.Filter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; @@ -181,12 +182,8 @@ public class QueryRestConfig extends WebMvcConfigurerAdapter { return new QueryValidator(); } -// @Bean -// public Filter regexCORSFilter() { -// return new RegexCORSFilter(); -// } - @Bean + @ConditionalOnProperty("queryrest.cors.enable") public Filter corsFilter() { return new CorsFilter(); } diff --git a/src/main/resources/queryrest.properties b/src/main/resources/queryrest.properties index 4acde24..9ee6bf6 100644 --- a/src/main/resources/queryrest.properties +++ b/src/main/resources/queryrest.properties @@ -6,12 +6,9 @@ queryrest.default.response.fields=channel,pulseId,globalMillis,globalNanos,iocMi queryrest.default.response.aggregations=min,max,sum # enables / disables the CORS servlet filter. Adds multiple CORS headers to the response -queryrest.enableCORS=true - +queryrest.cors.enable=true # includes the CORS headers no matter what request or preflight was sent. If an Origin header is set, this header will be used. # If no Origin header is set, '*' will be used. queryrest.cors.forceallheaders=true - -# defines a specific regex to be used in the Access-Control-Allow-Origin. This property needs to be specified -# but might be null or the empty string (""), i.e. don't comment it out. +# defines the allowed origins for CORS requests. Only relevant if queryrest.enableCORS==true (see above). queryrest.cors.allowedorigins=http://localhost:8080, * \ No newline at end of file