This repository has been archived by the owner on Jun 7, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable CORS on ribbon services. Make UI interactive.
- Loading branch information
Showing
5 changed files
with
140 additions
and
9 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
ribbon/events/src/main/java/org/wildfly/swarm/examples/netflix/ribbon/events/CORSFilter.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,23 @@ | ||
package org.wildfly.swarm.examples.netflix.ribbon.events; | ||
|
||
import javax.ws.rs.container.ContainerRequestContext; | ||
import javax.ws.rs.container.ContainerResponseContext; | ||
import javax.ws.rs.container.ContainerResponseFilter; | ||
import javax.ws.rs.ext.Provider; | ||
import java.io.IOException; | ||
|
||
/** | ||
* @author Lance Ball | ||
*/ | ||
@Provider | ||
public class CORSFilter implements ContainerResponseFilter { | ||
public void filter(ContainerRequestContext paramContainerRequestContext, | ||
ContainerResponseContext paramContainerResponseContext) | ||
throws IOException { | ||
paramContainerResponseContext.getHeaders().add("Access-Control-Allow-Origin", "*"); | ||
paramContainerResponseContext.getHeaders().add("Access-Control-Allow-Headers", "origin, content-type, accept, authorization"); | ||
paramContainerResponseContext.getHeaders().add("Access-Control-Allow-Credentials", "true"); | ||
paramContainerResponseContext.getHeaders().add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, HEAD"); | ||
paramContainerResponseContext.getHeaders().add("Access-Control-Max-Age", "1209600"); | ||
} | ||
} |
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
23 changes: 23 additions & 0 deletions
23
ribbon/time/src/main/java/org/wildfly/swarm/examples/netflix/ribbon/time/CORSFilter.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,23 @@ | ||
package org.wildfly.swarm.examples.netflix.ribbon.time; | ||
|
||
import javax.ws.rs.container.ContainerRequestContext; | ||
import javax.ws.rs.container.ContainerResponseContext; | ||
import javax.ws.rs.container.ContainerResponseFilter; | ||
import javax.ws.rs.ext.Provider; | ||
import java.io.IOException; | ||
|
||
/** | ||
* @author Lance Ball | ||
*/ | ||
@Provider | ||
public class CORSFilter implements ContainerResponseFilter { | ||
public void filter(ContainerRequestContext paramContainerRequestContext, | ||
ContainerResponseContext paramContainerResponseContext) | ||
throws IOException { | ||
paramContainerResponseContext.getHeaders().add("Access-Control-Allow-Origin", "*"); | ||
paramContainerResponseContext.getHeaders().add("Access-Control-Allow-Headers", "origin, content-type, accept, authorization"); | ||
paramContainerResponseContext.getHeaders().add("Access-Control-Allow-Credentials", "true"); | ||
paramContainerResponseContext.getHeaders().add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, HEAD"); | ||
paramContainerResponseContext.getHeaders().add("Access-Control-Max-Age", "1209600"); | ||
} | ||
} |
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