Package io.muserver.handlers
Class CORSHandlerBuilder
- java.lang.Object
-
- io.muserver.handlers.CORSHandlerBuilder
-
- All Implemented Interfaces:
MuHandlerBuilder<CORSHandler>
public class CORSHandlerBuilder extends java.lang.Object implements MuHandlerBuilder<CORSHandler>
Used to create a handler that puts appropriate CORS headers on requests.
Simply add this handler before any other handlers that you want CORS headers added to.
-
-
Constructor Summary
Constructors Constructor Description CORSHandlerBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CORSHandler
build()
static CORSConfigBuilder
config()
A helper for creating a config object to pass towithCORSConfig(CORSConfigBuilder)
static CORSHandlerBuilder
corsHandler()
A helper for creating a CORS handlerCORSHandlerBuilder
withAllowedMethods(Method... methods)
Specifies the headers allowed for CORS requests.CORSHandlerBuilder
withCORSConfig(CORSConfig corsConfig)
Sets the CORS configuration for the handlerCORSHandlerBuilder
withCORSConfig(CORSConfigBuilder corsConfig)
Sets the CORS configuration for the handler
-
-
-
Method Detail
-
withCORSConfig
public CORSHandlerBuilder withCORSConfig(CORSConfig corsConfig)
Sets the CORS configuration for the handler- Parameters:
corsConfig
- The config to use- Returns:
- This builder
-
withCORSConfig
public CORSHandlerBuilder withCORSConfig(CORSConfigBuilder corsConfig)
Sets the CORS configuration for the handler- Parameters:
corsConfig
- The config to use- Returns:
- This builder
-
withAllowedMethods
public CORSHandlerBuilder withAllowedMethods(Method... methods)
Specifies the headers allowed for CORS requests. Defaults to all methods except Trace and Connect.- Parameters:
methods
- The methods to allow, or null to allow all except Trace and Connect.- Returns:
- This builder.
-
config
public static CORSConfigBuilder config()
A helper for creating a config object to pass towithCORSConfig(CORSConfigBuilder)
- Returns:
- a CORS configuration object
-
corsHandler
public static CORSHandlerBuilder corsHandler()
A helper for creating a CORS handler- Returns:
- A new builder.
-
build
public CORSHandler build()
- Specified by:
build
in interfaceMuHandlerBuilder<CORSHandler>
- Returns:
- A newly built
MuHandler
-
-