@ConfigurationProperties(value="micronaut.server", cliPrefix="") public class HttpServerConfiguration extends java.lang.Object implements ServerContextPathProvider
A base ConfigurationProperties
for servers.
Modifier and Type | Class and Description |
---|---|
static class |
HttpServerConfiguration.CorsConfiguration
Configuration for CORS.
|
static class |
HttpServerConfiguration.HostResolutionConfiguration
Configuration for host resolution with the
HttpHostResolver . |
static class |
HttpServerConfiguration.MultipartConfiguration
Configuration for multipart handling.
|
Modifier and Type | Field and Description |
---|---|
static boolean |
DEFAULT_DATEHEADER
The default date header.
|
static boolean |
DEFAULT_DUAL_PROTOCOL
The default value for enabling dual protocol (http/https).
|
static long |
DEFAULT_IDLE_TIME_MINUTES
The default idle time.
|
static boolean |
DEFAULT_LOG_HANDLED_EXCEPTIONS
The default value for log handled exceptions.
|
static long |
DEFAULT_MAX_REQUEST_SIZE
The default max request size.
|
static int |
DEFAULT_PORT
The default port value.
|
static int |
DEFAULT_RANDOM_PORT
The default value random port.
|
static long |
DEFAULT_READ_IDLE_TIME_MINUTES
The default read idle time in minutes.
|
static long |
DEFAULT_WRITE_IDLE_TIME_MINUTES
The default write idle time in minutes.
|
static java.lang.String |
PREFIX
The prefix used for configuration.
|
Constructor and Description |
---|
HttpServerConfiguration()
Default constructor.
|
HttpServerConfiguration(ApplicationConfiguration applicationConfiguration) |
Modifier and Type | Method and Description |
---|---|
ApplicationConfiguration |
getApplicationConfiguration() |
java.lang.String |
getClientAddressHeader() |
java.lang.String |
getContextPath() |
HttpServerConfiguration.CorsConfiguration |
getCors() |
java.nio.charset.Charset |
getDefaultCharset() |
java.util.Optional<java.lang.String> |
getHost() |
HttpServerConfiguration.HostResolutionConfiguration |
getHostResolution() |
HttpVersion |
getHttpVersion()
The HTTP version to use.
|
java.time.Duration |
getIdleTimeout() |
long |
getMaxRequestSize() |
HttpServerConfiguration.MultipartConfiguration |
getMultipart() |
java.util.Optional<java.lang.Integer> |
getPort() |
java.time.Duration |
getReadIdleTimeout() |
java.util.Optional<java.lang.Integer> |
getReadTimeout() |
java.util.Optional<java.lang.String> |
getServerHeader() |
ThreadSelection |
getThreadSelection() |
java.time.Duration |
getWriteIdleTimeout() |
boolean |
isDateHeader() |
boolean |
isDualProtocol() |
boolean |
isLogHandledExceptions() |
void |
setClientAddressHeader(java.lang.String clientAddressHeader) |
void |
setContextPath(java.lang.String contextPath)
Sets the context path for the web server.
|
void |
setCors(HttpServerConfiguration.CorsConfiguration cors)
Sets the cors configuration.
|
void |
setDateHeader(boolean dateHeader)
Sets whether a date header should be sent back.
|
void |
setDefaultCharset(java.nio.charset.Charset defaultCharset) |
void |
setDualProtocol(boolean dualProtocol) |
void |
setHost(java.lang.String host)
Sets the host to bind to.
|
void |
setHostResolution(HttpServerConfiguration.HostResolutionConfiguration hostResolution) |
void |
setHttpVersion(HttpVersion httpVersion)
Sets the HTTP version to use.
|
void |
setIdleTimeout(java.time.Duration idleTimeout)
Sets the idle time of connections for the server.
|
void |
setLogHandledExceptions(boolean logHandledExceptions)
Sets whether exceptions handled by either an error route or exception handler
should still be logged.
|
void |
setMaxRequestSize(long maxRequestSize)
Sets the maximum request size.
|
void |
setMultipart(HttpServerConfiguration.MultipartConfiguration multipart)
Sets the multipart configuration.
|
void |
setPort(int port)
Sets the port to bind to.
|
void |
setReadIdleTimeout(java.time.Duration readIdleTimeout)
Sets the amount of time a connection can remain idle without any reads occurring.
|
void |
setReadTimeout(java.lang.Integer readTimeout)
Sets the default read timeout.
|
void |
setServerHeader(java.lang.String serverHeader)
Sets the name of the server header.
|
void |
setThreadSelection(ThreadSelection threadSelection)
Sets the
ThreadSelection model to use for the server. |
void |
setWriteIdleTimeout(java.time.Duration writeIdleTimeout)
Sets the amount of time a connection can remain idle without any writes occurring.
|
public static final int DEFAULT_PORT
public static final java.lang.String PREFIX
public static final int DEFAULT_RANDOM_PORT
public static final long DEFAULT_MAX_REQUEST_SIZE
public static final long DEFAULT_READ_IDLE_TIME_MINUTES
public static final long DEFAULT_WRITE_IDLE_TIME_MINUTES
public static final boolean DEFAULT_DATEHEADER
public static final long DEFAULT_IDLE_TIME_MINUTES
public static final boolean DEFAULT_LOG_HANDLED_EXCEPTIONS
public static final boolean DEFAULT_DUAL_PROTOCOL
public HttpServerConfiguration()
@Inject public HttpServerConfiguration(ApplicationConfiguration applicationConfiguration)
applicationConfiguration
- The application configurationpublic HttpVersion getHttpVersion()
HttpVersion.HTTP_1_1
.public void setHttpVersion(HttpVersion httpVersion)
HttpVersion.HTTP_1_1
.httpVersion
- The http version@NonNull public ThreadSelection getThreadSelection()
ThreadSelection
model to use for the server.public void setThreadSelection(ThreadSelection threadSelection)
ThreadSelection
model to use for the server.threadSelection
- The thread selection modelpublic ApplicationConfiguration getApplicationConfiguration()
public java.nio.charset.Charset getDefaultCharset()
public java.util.Optional<java.lang.Integer> getPort()
public java.util.Optional<java.lang.String> getHost()
public java.util.Optional<java.lang.Integer> getReadTimeout()
public HttpServerConfiguration.MultipartConfiguration getMultipart()
public HttpServerConfiguration.CorsConfiguration getCors()
public long getMaxRequestSize()
public java.time.Duration getReadIdleTimeout()
public java.time.Duration getWriteIdleTimeout()
public java.time.Duration getIdleTimeout()
public java.util.Optional<java.lang.String> getServerHeader()
public boolean isDateHeader()
public boolean isLogHandledExceptions()
@Nullable public HttpServerConfiguration.HostResolutionConfiguration getHostResolution()
public java.lang.String getClientAddressHeader()
public java.lang.String getContextPath()
getContextPath
in interface ServerContextPathProvider
public boolean isDualProtocol()
public void setDefaultCharset(java.nio.charset.Charset defaultCharset)
defaultCharset
- The default charset to usepublic void setPort(int port)
port
- The portpublic void setHost(java.lang.String host)
host
- The hostpublic void setReadTimeout(java.lang.Integer readTimeout)
readTimeout
- The read timeoutpublic void setServerHeader(java.lang.String serverHeader)
serverHeader
- The server headerpublic void setMaxRequestSize(@ReadableBytes long maxRequestSize)
maxRequestSize
- The max request sizepublic void setReadIdleTimeout(java.time.Duration readIdleTimeout)
readIdleTimeout
- The read idle timepublic void setWriteIdleTimeout(java.time.Duration writeIdleTimeout)
writeIdleTimeout
- The write idle timepublic void setIdleTimeout(java.time.Duration idleTimeout)
idleTimeout
- The idle timepublic void setMultipart(HttpServerConfiguration.MultipartConfiguration multipart)
multipart
- The multipart configurationpublic void setCors(HttpServerConfiguration.CorsConfiguration cors)
cors
- The cors configurationpublic void setDateHeader(boolean dateHeader)
dateHeader
- True if a date header should be sent.public void setLogHandledExceptions(boolean logHandledExceptions)
logHandledExceptions
- True if exceptions should be loggedpublic void setHostResolution(HttpServerConfiguration.HostResolutionConfiguration hostResolution)
hostResolution
- The host resolution configurationpublic void setClientAddressHeader(java.lang.String clientAddressHeader)
clientAddressHeader
- The header that stores the original client addresspublic void setContextPath(java.lang.String contextPath)
contextPath
- the context path for the web serverpublic void setDualProtocol(boolean dualProtocol)
dualProtocol
- the dual protocol (http/https) configuration