forked from mapfish/mapfish-print
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes mapfish#504
- Loading branch information
Patrick Valsecchi
committed
Mar 7, 2017
1 parent
58a6748
commit 0f6d2fa
Showing
6 changed files
with
90 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
core/src/main/java/org/mapfish/print/servlet/CorsFilterHandlerInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.mapfish.print.servlet; | ||
|
||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
/** | ||
* Filter that adds CORS headers to every response. | ||
*/ | ||
public final class CorsFilterHandlerInterceptor extends HandlerInterceptorAdapter { | ||
/** | ||
* Called before the reponse is built. | ||
* | ||
* @param request The request | ||
* @param response The response | ||
* @param handler The handler | ||
*/@Override | ||
public boolean preHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler) throws Exception { | ||
if (request.getHeader("Origin") != null && !response.containsHeader("Access-Control-Allow-Origin")) { | ||
response.setHeader("Access-Control-Allow-Origin", "*"); | ||
} | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters