Package io.micronaut.http.server
Class HttpServerConfiguration
java.lang.Object
io.micronaut.http.server.HttpServerConfiguration
- All Implemented Interfaces:
io.micronaut.http.context.ServerContextPathProvider
@ConfigurationProperties(value="micronaut.server",
cliPrefix="")
public class HttpServerConfiguration
extends Object
implements io.micronaut.http.context.ServerContextPathProvider
A base ConfigurationProperties for servers.
- Since:
- 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classConfiguration for CORS.static classConfiguration for host resolution with theHttpHostResolver.static classConfiguration for locale resolution used byHttpLocaleResolver.static classConfiguration for multipart handling. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanThe default date header.static final booleanThe default value for enabling dual protocol (http/https).static final booleanThe default value for redirect HTTP to HTTPS when using dual protocal.static final longThe default idle time.static final booleanThe default value for log handled exceptions.static final longThe default max request size.static final intThe default port value.static final intThe default value random port.static final longThe default read idle time in minutes.static final longThe default write idle time in minutes.static final StringThe prefix used for configuration. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.HttpServerConfiguration(io.micronaut.runtime.ApplicationConfiguration applicationConfiguration) -
Method Summary
Modifier and TypeMethodDescriptionio.micronaut.runtime.ApplicationConfigurationgetCors()getHost()io.micronaut.http.HttpVersionThe HTTP version to use.longgetPort()Deprecated.This setting does nothingio.micronaut.scheduling.executor.ThreadSelectionbooleanbooleanbooleanbooleanvoidsetClientAddressHeader(String clientAddressHeader) voidsetContextPath(String contextPath) Sets the context path for the web server.voidSets the cors configuration.voidsetDateHeader(boolean dateHeader) Sets whether a date header should be sent back.voidsetDefaultCharset(Charset defaultCharset) voidsetDualProtocol(boolean dualProtocol) voidSets the host to bind to.voidsetHostResolution(HttpServerConfiguration.HostResolutionConfiguration hostResolution) voidsetHttpToHttpsRedirect(boolean httpToHttpsRedirect) voidsetHttpVersion(io.micronaut.http.HttpVersion httpVersion) Sets the HTTP version to use.voidsetIdleTimeout(Duration idleTimeout) Sets the idle time of connections for the server.voidsetLocaleResolution(HttpServerConfiguration.HttpLocaleResolutionConfigurationProperties localeResolution) voidsetLogHandledExceptions(boolean logHandledExceptions) Sets whether exceptions handled by either an error route or exception handler should still be logged.voidsetMaxRequestSize(long maxRequestSize) Sets the maximum request size.voidSets the multipart configuration.voidsetPort(int port) Sets the port to bind to.voidsetReadIdleTimeout(Duration readIdleTimeout) Sets the amount of time a connection can remain idle without any reads occurring.voidsetReadTimeout(Integer readTimeout) Deprecated.This setting does nothingvoidsetServerHeader(String serverHeader) Sets the name of the server header.voidsetThreadSelection(io.micronaut.scheduling.executor.ThreadSelection threadSelection) Sets theThreadSelectionmodel to use for the server.voidsetWriteIdleTimeout(Duration writeIdleTimeout) Sets the amount of time a connection can remain idle without any writes occurring.
-
Field Details
-
DEFAULT_PORT
public static final int DEFAULT_PORTThe default port value.- See Also:
-
PREFIX
The prefix used for configuration.- See Also:
-
DEFAULT_RANDOM_PORT
public static final int DEFAULT_RANDOM_PORTThe default value random port.- See Also:
-
DEFAULT_MAX_REQUEST_SIZE
public static final long DEFAULT_MAX_REQUEST_SIZEThe default max request size.- See Also:
-
DEFAULT_READ_IDLE_TIME_MINUTES
public static final long DEFAULT_READ_IDLE_TIME_MINUTESThe default read idle time in minutes.- See Also:
-
DEFAULT_WRITE_IDLE_TIME_MINUTES
public static final long DEFAULT_WRITE_IDLE_TIME_MINUTESThe default write idle time in minutes.- See Also:
-
DEFAULT_DATEHEADER
public static final boolean DEFAULT_DATEHEADERThe default date header.- See Also:
-
DEFAULT_IDLE_TIME_MINUTES
public static final long DEFAULT_IDLE_TIME_MINUTESThe default idle time.- See Also:
-
DEFAULT_LOG_HANDLED_EXCEPTIONS
public static final boolean DEFAULT_LOG_HANDLED_EXCEPTIONSThe default value for log handled exceptions.- See Also:
-
DEFAULT_DUAL_PROTOCOL
public static final boolean DEFAULT_DUAL_PROTOCOLThe default value for enabling dual protocol (http/https).- See Also:
-
DEFAULT_HTTP_TO_HTTPS_REDIRECT
public static final boolean DEFAULT_HTTP_TO_HTTPS_REDIRECTThe default value for redirect HTTP to HTTPS when using dual protocal.- See Also:
-
-
Constructor Details
-
HttpServerConfiguration
public HttpServerConfiguration()Default constructor. -
HttpServerConfiguration
@Inject public HttpServerConfiguration(io.micronaut.runtime.ApplicationConfiguration applicationConfiguration) - Parameters:
applicationConfiguration- The application configuration
-
-
Method Details
-
getHttpVersion
public io.micronaut.http.HttpVersion getHttpVersion()The HTTP version to use. Defaults toHttpVersion.HTTP_1_1.- Returns:
- The http version
-
setHttpVersion
public void setHttpVersion(io.micronaut.http.HttpVersion httpVersion) Sets the HTTP version to use. Defaults toHttpVersion.HTTP_1_1.- Parameters:
httpVersion- The http version
-
getThreadSelection
@NonNull public io.micronaut.scheduling.executor.ThreadSelection getThreadSelection()- Returns:
- The
ThreadSelectionmodel to use for the server.
-
setThreadSelection
public void setThreadSelection(io.micronaut.scheduling.executor.ThreadSelection threadSelection) Sets theThreadSelectionmodel to use for the server. Default value MANUAL.- Parameters:
threadSelection- The thread selection model
-
getApplicationConfiguration
public io.micronaut.runtime.ApplicationConfiguration getApplicationConfiguration()- Returns:
- The application configuration instance
-
getDefaultCharset
- Returns:
- The default charset to use
-
getPort
- Returns:
- The default server port
-
getHost
- Returns:
- The default host
-
getReadTimeout
Deprecated.This setting does nothing- Returns:
- The read timeout setting for the server
-
getMultipart
- Returns:
- Configuration for multipart / file uploads
-
getCors
- Returns:
- Configuration for CORS
-
getMaxRequestSize
public long getMaxRequestSize()- Returns:
- The maximum request body size
-
getReadIdleTimeout
- Returns:
- The default amount of time to allow read operation connections to remain idle
-
getWriteIdleTimeout
- Returns:
- The default amount of time to allow write operation connections to remain idle
-
getIdleTimeout
- Returns:
- The time to allow an idle connection for
-
getServerHeader
- Returns:
- The optional server header value
-
isDateHeader
public boolean isDateHeader()- Returns:
- True if the date header should be set
-
isLogHandledExceptions
public boolean isLogHandledExceptions()- Returns:
- True if exceptions handled by either an error route or exception handler should be logged
-
getHostResolution
- Returns:
- The host resolution configuration
-
getLocaleResolution
- Returns:
- The host resolution configuration
-
getClientAddressHeader
- Returns:
- Which header stores the original client
-
getContextPath
- Specified by:
getContextPathin interfaceio.micronaut.http.context.ServerContextPathProvider- Returns:
- the context path for the web server
-
isDualProtocol
public boolean isDualProtocol()- Returns:
- if dual protocol has been enabled or not
-
isHttpToHttpsRedirect
public boolean isHttpToHttpsRedirect()- Returns:
- if redirection from HTTP to HTTPS is enabled or not
-
setDefaultCharset
- Parameters:
defaultCharset- The default charset to use
-
setPort
public void setPort(int port) Sets the port to bind to. Default value (-1)- Parameters:
port- The port
-
setHost
Sets the host to bind to.- Parameters:
host- The host
-
setReadTimeout
Deprecated.This setting does nothingSets the default read timeout.- Parameters:
readTimeout- The read timeout
-
setServerHeader
Sets the name of the server header.- Parameters:
serverHeader- The server header
-
setMaxRequestSize
public void setMaxRequestSize(@ReadableBytes long maxRequestSize) Sets the maximum request size. Default value (10485760L => // 10MB)- Parameters:
maxRequestSize- The max request size
-
setReadIdleTimeout
Sets the amount of time a connection can remain idle without any reads occurring. Default value (5L minutes).- Parameters:
readIdleTimeout- The read idle time
-
setWriteIdleTimeout
Sets the amount of time a connection can remain idle without any writes occurring. Default value (5L minutes).- Parameters:
writeIdleTimeout- The write idle time
-
setIdleTimeout
Sets the idle time of connections for the server. Default value (5L minutes).- Parameters:
idleTimeout- The idle time
-
setMultipart
Sets the multipart configuration.- Parameters:
multipart- The multipart configuration
-
setCors
Sets the cors configuration.- Parameters:
cors- The cors configuration
-
setDateHeader
public void setDateHeader(boolean dateHeader) Sets whether a date header should be sent back. Default value (true).- Parameters:
dateHeader- True if a date header should be sent.
-
setLogHandledExceptions
public void setLogHandledExceptions(boolean logHandledExceptions) Sets whether exceptions handled by either an error route or exception handler should still be logged. Default value (false).- Parameters:
logHandledExceptions- True if exceptions should be logged
-
setHostResolution
- Parameters:
hostResolution- The host resolution configuration
-
setLocaleResolution
public void setLocaleResolution(HttpServerConfiguration.HttpLocaleResolutionConfigurationProperties localeResolution) - Parameters:
localeResolution- The locale resolution configuration
-
setClientAddressHeader
- Parameters:
clientAddressHeader- The header that stores the original client address
-
setContextPath
Sets the context path for the web server.- Parameters:
contextPath- the context path for the web server
-
setDualProtocol
public void setDualProtocol(boolean dualProtocol) - Parameters:
dualProtocol- the dual protocol (http/https) configuration. Default value (false).
-
setHttpToHttpsRedirect
public void setHttpToHttpsRedirect(boolean httpToHttpsRedirect) - Parameters:
httpToHttpsRedirect- Set to true to enable redirecting all http requests to the same URL but with https instead. This should only be used whendualProtocolis enabled. Default value (false). This feature uses the host resolution capabilities to determine the host to redirect to.
-