@ConfigurationProperties(value="micronaut.server", cliPrefix="") public class HttpServerConfiguration extends 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.HttpLocaleResolutionConfigurationProperties
Configuration for locale resolution used by
HttpLocaleResolver . |
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 boolean |
DEFAULT_HTTP_TO_HTTPS_REDIRECT
The default value for redirect HTTP to HTTPS when using dual protocal.
|
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 String |
PREFIX
The prefix used for configuration.
|
Constructor and Description |
---|
HttpServerConfiguration()
Default constructor.
|
HttpServerConfiguration(ApplicationConfiguration applicationConfiguration) |
Modifier and Type | Method and Description |
---|---|
ApplicationConfiguration |
getApplicationConfiguration() |
String |
getClientAddressHeader() |
String |
getContextPath() |
HttpServerConfiguration.CorsConfiguration |
getCors() |
Charset |
getDefaultCharset() |
Optional<String> |
getHost() |
HttpServerConfiguration.HostResolutionConfiguration |
getHostResolution() |
HttpVersion |
getHttpVersion()
The HTTP version to use.
|
Duration |
getIdleTimeout() |
HttpLocaleResolutionConfiguration |
getLocaleResolution() |
long |
getMaxRequestSize() |
HttpServerConfiguration.MultipartConfiguration |
getMultipart() |
Optional<Integer> |
getPort() |
Duration |
getReadIdleTimeout() |
Optional<Integer> |
getReadTimeout() |
Optional<String> |
getServerHeader() |
ThreadSelection |
getThreadSelection() |
Duration |
getWriteIdleTimeout() |
boolean |
isDateHeader() |
boolean |
isDualProtocol() |
boolean |
isHttpToHttpsRedirect() |
boolean |
isLogHandledExceptions() |
void |
setClientAddressHeader(String clientAddressHeader) |
void |
setContextPath(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(Charset defaultCharset) |
void |
setDualProtocol(boolean dualProtocol) |
void |
setHost(String host)
Sets the host to bind to.
|
void |
setHostResolution(HttpServerConfiguration.HostResolutionConfiguration hostResolution) |
void |
setHttpToHttpsRedirect(boolean httpToHttpsRedirect) |
void |
setHttpVersion(HttpVersion httpVersion)
Sets the HTTP version to use.
|
void |
setIdleTimeout(Duration idleTimeout)
Sets the idle time of connections for the server.
|
void |
setLocaleResolution(HttpServerConfiguration.HttpLocaleResolutionConfigurationProperties localeResolution) |
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(Duration readIdleTimeout)
Sets the amount of time a connection can remain idle without any reads occurring.
|
void |
setReadTimeout(Integer readTimeout)
Sets the default read timeout.
|
void |
setServerHeader(String serverHeader)
Sets the name of the server header.
|
void |
setThreadSelection(ThreadSelection threadSelection)
Sets the
ThreadSelection model to use for the server. |
void |
setWriteIdleTimeout(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 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 static final boolean DEFAULT_HTTP_TO_HTTPS_REDIRECT
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 Charset getDefaultCharset()
public Optional<Integer> getReadTimeout()
public HttpServerConfiguration.MultipartConfiguration getMultipart()
public HttpServerConfiguration.CorsConfiguration getCors()
public long getMaxRequestSize()
public Duration getReadIdleTimeout()
public Duration getWriteIdleTimeout()
public Duration getIdleTimeout()
public boolean isDateHeader()
public boolean isLogHandledExceptions()
@Nullable public HttpServerConfiguration.HostResolutionConfiguration getHostResolution()
@Nullable public HttpLocaleResolutionConfiguration getLocaleResolution()
public String getClientAddressHeader()
public String getContextPath()
getContextPath
in interface ServerContextPathProvider
public boolean isDualProtocol()
public boolean isHttpToHttpsRedirect()
public void setDefaultCharset(Charset defaultCharset)
defaultCharset
- The default charset to usepublic void setPort(int port)
port
- The portpublic void setHost(String host)
host
- The hostpublic void setReadTimeout(Integer readTimeout)
readTimeout
- The read timeoutpublic void setServerHeader(String serverHeader)
serverHeader
- The server headerpublic void setMaxRequestSize(@ReadableBytes long maxRequestSize)
maxRequestSize
- The max request sizepublic void setReadIdleTimeout(Duration readIdleTimeout)
readIdleTimeout
- The read idle timepublic void setWriteIdleTimeout(Duration writeIdleTimeout)
writeIdleTimeout
- The write idle timepublic void setIdleTimeout(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 setLocaleResolution(HttpServerConfiguration.HttpLocaleResolutionConfigurationProperties localeResolution)
localeResolution
- The locale resolution configurationpublic void setClientAddressHeader(String clientAddressHeader)
clientAddressHeader
- The header that stores the original client addresspublic void setContextPath(String contextPath)
contextPath
- the context path for the web serverpublic void setDualProtocol(boolean dualProtocol)
dualProtocol
- the dual protocol (http/https) configuration. Default value (false).public void setHttpToHttpsRedirect(boolean httpToHttpsRedirect)
httpToHttpsRedirect
- Set to true to enable redirecting all http requests to the same URL but with
https instead. This should only be used when dualProtocol
is enabled.
Default value (false). This feature uses
the host resolution capabilities to determine the host to redirect to.