Class CorsInterceptor
- java.lang.Object
-
- ca.uhn.fhir.rest.server.interceptor.InterceptorAdapter
-
- ca.uhn.fhir.rest.server.interceptor.CorsInterceptor
-
- All Implemented Interfaces:
IServerInterceptor
public class CorsInterceptor extends InterceptorAdapter
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface ca.uhn.fhir.rest.server.interceptor.IServerInterceptor
IServerInterceptor.ActionRequestDetails
-
-
Constructor Summary
Constructors Constructor Description CorsInterceptor()Constructor which creates an interceptor with default CORS configuration for use in a FHIR server.CorsInterceptor(org.springframework.web.cors.CorsConfiguration theConfiguration)Constructor which accepts the given configuration
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.springframework.web.cors.CorsConfigurationgetConfig()Gets the CORS configurationbooleanincomingRequestPreProcessed(javax.servlet.http.HttpServletRequest theRequest, javax.servlet.http.HttpServletResponse theResponse)This method is called before any other processing takes place for each incoming request.voidsetConfig(org.springframework.web.cors.CorsConfiguration theConfiguration)Sets the CORS configuration-
Methods inherited from class ca.uhn.fhir.rest.server.interceptor.InterceptorAdapter
handleException, incomingRequestPostProcessed, incomingRequestPreHandled, outgoingResponse, outgoingResponse, outgoingResponse, outgoingResponse, outgoingResponse, outgoingResponse, outgoingResponse, preProcessOutgoingException, processingCompletedNormally
-
-
-
-
Constructor Detail
-
CorsInterceptor
public CorsInterceptor()
Constructor which creates an interceptor with default CORS configuration for use in a FHIR server. This includes:- Allowed Origin: *
- Allowed Header: Accept
- Allowed Header: Access-Control-Request-Headers
- Allowed Header: Access-Control-Request-Method
- Allowed Header: Cache-Control
- Exposed Header: Content-Location
- Allowed Header: Content-Type
- Exposed Header: Location
- Allowed Header: Origin
- Allowed Header: Prefer
- Allowed Header: X-Requested-With
-
CorsInterceptor
public CorsInterceptor(org.springframework.web.cors.CorsConfiguration theConfiguration)
Constructor which accepts the given configuration- Parameters:
theConfiguration- The CORS configuration
-
-
Method Detail
-
getConfig
public org.springframework.web.cors.CorsConfiguration getConfig()
Gets the CORS configuration
-
setConfig
public void setConfig(org.springframework.web.cors.CorsConfiguration theConfiguration)
Sets the CORS configuration
-
incomingRequestPreProcessed
public boolean incomingRequestPreProcessed(javax.servlet.http.HttpServletRequest theRequest, javax.servlet.http.HttpServletResponse theResponse)
Description copied from interface:IServerInterceptorThis method is called before any other processing takes place for each incoming request. It may be used to provide alternate handling for some requests, or to screen requests before they are handled, etc.Note that any exceptions thrown by this method will not be trapped by HAPI (they will be passed up to the server)
- Specified by:
incomingRequestPreProcessedin interfaceIServerInterceptor- Overrides:
incomingRequestPreProcessedin classInterceptorAdapter- Parameters:
theRequest- The incoming requesttheResponse- The response. Note that interceptors may choose to provide a response (i.e. by callingServletResponse.getWriter()) but in that case it is important to returnfalseto indicate that the server itself should not also provide a response.- Returns:
- Return
trueif processing should continue normally. This is generally the right thing to do. If your interceptor is providing a response rather than letting HAPI handle the response normally, you must returnfalse. In this case, no further processing will occur and no further interceptors will be called.
-
-