public static class HttpServer.HttpServerBuilder extends Object
HttpServer.HttpServerBuilder
builder.Modifier and Type | Method and Description |
---|---|
HttpServer.HttpServerBuilder |
apiBase(String apiBase)
Add a path common base that will be appended to all routes mapped without starting with a forward slash '/'.
|
HttpServer |
build()
Builds and returns an instance of
HttpServer with the configured parameters. |
HttpServer.HttpServerBuilder |
connectionTimeout(int connectionTimeout)
By default, server is configured to keep connection open during one minute if possible.
|
HttpServer.HttpServerBuilder |
developmentMode()
Activate development mode.
|
HttpServer.HttpServerBuilder |
encodingRegistry(EncodingRegistry encodingRegistry)
If this method is not called an instance of
EncodingRegistry is used by the server. |
HttpServer.HttpServerBuilder |
port(int port)
Set the server port number.
|
HttpServer.HttpServerBuilder |
secure(ServerSocketFactory ssf)
Set Server Socket Factory.
|
HttpServer.HttpServerBuilder |
simultaneousConnections(int simultaneousConnections)
Set the max simultaneous connections.
|
HttpServer.HttpServerBuilder |
staticFilesHandler(StaticFilesHandler handler)
Set the static files handler to serve static files.
|
HttpServer.HttpServerBuilder |
withStrictAcceptContentEncoding()
RFC2616 14.3
Activate strict content encoding acceptance.
|
HttpServer.HttpServerBuilder |
withTrailingSlashSupport()
Activate trailing slash matching support in URI.
|
HttpServer.HttpServerBuilder |
workerCount(int workerCount)
Set threads count that handles incoming request.
|
public HttpServer.HttpServerBuilder apiBase(@Nullable String apiBase)
apiBase
- the api base pathHttpServer.HttpServerBuilder
to continue setting up the server parametersIllegalArgumentException
- if apiBase is null or emptypublic HttpServer build()
HttpServer
with the configured parameters.HttpServer
with the configured parameters.public HttpServer.HttpServerBuilder connectionTimeout(int connectionTimeout)
connectionTimeout
- the timeout duration.HttpServer.HttpServerBuilder
to continue setting up the server parametersIllegalArgumentException
- if connectionTimeout < 0
public HttpServer.HttpServerBuilder developmentMode()
HttpServer.HttpServerBuilder
to continue setting up the server parameterspublic HttpServer.HttpServerBuilder encodingRegistry(@Nullable EncodingRegistry encodingRegistry)
EncodingRegistry
is used by the server.encodingRegistry
- the registry of available encoding handlers.HttpServer.HttpServerBuilder
to continue setting up the server parametersIllegalArgumentException
- if encodingRegistry is nullpublic HttpServer.HttpServerBuilder port(int port)
port
- server port. use 0 set setup a random available port.HttpServer.HttpServerBuilder
to continue setting up the server parametersIllegalArgumentException
- if port is < 0
public HttpServer.HttpServerBuilder secure(@Nullable ServerSocketFactory ssf)
ssf
- Server socket factory to setup HTTPSHttpServer.HttpServerBuilder
to continue setting up the server parametersIllegalArgumentException
- if ServerSocketFactory parameter is nullpublic HttpServer.HttpServerBuilder simultaneousConnections(int simultaneousConnections)
simultaneousConnections
- max simultaneous connections that can be handled by the server.HttpServer.HttpServerBuilder
to continue setting up the server parametersIllegalArgumentException
- - if simultaneousConnections is <= 0
;public HttpServer.HttpServerBuilder staticFilesHandler(@Nullable StaticFilesHandler handler)
handler
- the StaticFilesHandler
instanceHttpServer.HttpServerBuilder
to continue setting up the server parametersIllegalArgumentException
- if the handler is nullpublic HttpServer.HttpServerBuilder withStrictAcceptContentEncoding()
EncodingRegistry.registerContentEncoding(ContentEncoding)
HttpServer.HttpServerBuilder
to continue setting up the server parameterspublic HttpServer.HttpServerBuilder withTrailingSlashSupport()
HttpServer.HttpServerBuilder
to continue setting up the server parameterspublic HttpServer.HttpServerBuilder workerCount(int workerCount)
workerCount
- number of threads to handle incoming requestsHttpServer.HttpServerBuilder
to continue setting up the server parametersIllegalArgumentException
- - if workerCount is <= 0
;