Skip to content

Instantly share code, notes, and snippets.

@tganzarolli
Created January 20, 2014 14:25
Show Gist options
  • Save tganzarolli/8520728 to your computer and use it in GitHub Desktop.
Save tganzarolli/8520728 to your computer and use it in GitHub Desktop.
A RestEasy service to return a default OK response for a CORS pre-flight request. Those requests are made when you are using CORS along with authentication headers. Using Jetty, the org.eclipse.jetty.servlets.CrossOriginFilter configured on the web.xml can take care of sending the required headers on the response. However, it does not care of re…
import javax.ws.rs.OPTIONS;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.springframework.stereotype.Service;
@Produces(MediaType.APPLICATION_JSON)
@Path("/")
@Service
public class CorsPreFlightService {
@OPTIONS
@Path("/{var:.*}")
public Response defaultOptions() {
return ResponseObject.ok("").buildResponse(200);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment