JdkHttpServerOptions

sttp.tapir.server.jdkhttp.JdkHttpServerOptions
See theJdkHttpServerOptions companion object
case class JdkHttpServerOptions(interceptors: List[Interceptor[Id]], createFile: ServerRequest => TapirFile, deleteFile: TapirFile => Unit, send404WhenRequestNotHandled: Boolean, basePath: String, port: Int, host: String, executor: Option[Executor], httpsConfigurator: Option[HttpsConfigurator], backlogSize: Int, multipartFileThresholdBytes: Long)

Value parameters

backlogSize

Sets the size of server's tcp connection backlog. This is the maximum number of queued incoming connections to allow on the listening socket. Queued TCP connections exceeding this limit may be rejected by the TCP implementation. If set to 0 or less the system default for backlog size will be used. Default is 0.

basePath

Path under which endpoints will be mounted when mounted on JdkHttpServer instance. I.e.: basePath of '/api' and endpoint '/hello' will result with a real path of '/api/hello'.

executor

Optional executor to be used to dispatch HTTP requests. By default JDK http server uses calling thread executor so only single thread is being used for all the work. This might be fine for toy projects but for any actual load it is recommended to use an Executor built by JdkHttpServerOptions.httpExecutor utility method or by providing an executor on your own. If running with JDK 19+ one can provide the Virtual Thread executor to leverage Project Loom.

host

Hostname or IP address (ie.: localhost, 0.0.0.0) to which JdkHttpServer instance will be bound. Default is 0.0.0.0 which binds the server to all network interfaces available on the OS.

httpsConfigurator

Optional HTTPS configuration. Takes an instance of com.sun.net.httpserver.HttpsConfigurator, which is a thin wrapper around javax.net.ssl.SSLContext to configure the SSL termination for this server.

multipartFileThresholdBytes

Sets the threshold of bytes of a multipart upload to trigger writing the multipart contents to a temporary file rather than keeping it entirely in memory. Default is 50MB.

port

IP port to which JdkHttpServer instance will be bound. Default is 0, which means any random port provided by the OS.

send404WhenRequestNotHandled

Should a 404 response be sent, when the request hasn't been handled. This is a safe default, but if there are multiple handlers for the same context path, this should be set to false. In that case, you can verify if the request has been handled using JdkHttpServerInterpreter.isRequestHandled.

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def appendInterceptor(i: Interceptor[Id]): JdkHttpServerOptions

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product