RingoJS

Module ringo/httpserver/builder

A module for configuring an http(s) server

Class HttpServerBuilder

Instance Methods


HttpServerBuilder ()

HttpServerBuilder constructor

See


HttpServerBuilder.prototype. addEventSource (path, onConnect, initParams)

Adds an EventSource connnector to the current application context, which must have been configured before.

Parameters

String path

The path of the EventSource connector

Function onConnect

An optional callback function invoked with the EventSource instance and the request object as arguments

Object initParams

An object containing servlet init parameters (see org.eclipse.jetty.servlets.EventSourceServlet)

Returns

HttpServerBuilder

HttpServerBuilder.prototype. addFilter (path, filter, initParams)

Adds a servlet filter to the chain of the current application context, which must have been configured before.

Parameters

String path

The path spec of this filter

jakarta.servlet.Filter filter

The filter to add

Object initParams

An object containing init parameters to pass to the org.eclipse.jetty.servlet.FilterHolder

Returns

HttpServerBuilder

HttpServerBuilder.prototype. addWebSocket (path, onConnect, onCreate, initParams)

Adds a websocket connector to the current application context., which must have been configured before.

Parameters

String path

The path of the websocket connector

Function onConnect

An optional callback function invoked with the websocket and the session as arguments

Function onCreate

An optional callback function invoked with the request and response objects as arguments. If this callback returns a value other than true, the connection is aborted.

Object initParams

An object containing servlet init parameters (see org.eclipse.jetty.websocket.servlet.WebSocketServlet

Returns

HttpServerBuilder

HttpServerBuilder.prototype. configure (xmlPath)

Configures the HttpServer with the jetty.xml configuration file

Parameters

String xmlPath

The path to the jetty.xml configuration file

Returns

HttpServerBuilder

HttpServerBuilder.prototype. enableConnectionStatistics ()

Enables statistics for all connectors

Returns

HttpServerBuilder

HttpServerBuilder.prototype. enableSessions (options)

Enables sessions with the specified options

Parameters

Object options

An object containing the following options:

  • name: (String, default: "node1") The worker name that is appended to the session ID
  • random: (java.util.Random, default: null) A random number generator to use for session IDs

Returns

HttpServerBuilder

HttpServerBuilder.prototype. http (options)

Configures a HTTP listener with the specified options

Parameters

Object options

An object containing the following options:

  • host: (String, default: "0.0.0.0")
  • port: (Number, default: 8080)
  • requestHeaderSize: (Number, default: 8129) The maximum size of request headers allowed
  • outputBufferSize: (Number, default: 32768) Sets the size of the buffer into which response content is aggregated before being sent to the client
  • responseHeaderSize: (Number, default: 8129) The maximum size of response headers
  • sendServerVersion: (boolean, default: false) Includes the Jetty server version in responses
  • sendDateHeader: (boolean, default: true) Enables/disables Date header in responses
  • secureScheme: (String, default: "https") Defines the URI scheme used for confidential and integral redirections

Returns

HttpServerBuilder

HttpServerBuilder.prototype. https (options)

Configures a HTTPS listener with the specified options

Parameters

Object options

An object containing the following options:

  • host: (String, default: "0.0.0.0")
  • port: (Number, default: 8443)
  • sniHostCheck: (boolean, default: true) If true the SNI Host name must match when there is an SNI certificate.
  • stsMaxAgeSeconds: (Number, default: -1) The max age in seconds for a Strict-Transport-Security response header (-1 means no header is sent)
  • stsIncludeSubdomains: (boolean, default: false) If true a include subdomain property is sent with any Strict-Transport-Security header
  • requestHeaderSize: (Number, default: 8129) The maximum size of request headers allowed
  • outputBufferSize: (Number, default: 32768) Sets the size of the buffer into which response content is aggregated before being sent to the client
  • responseHeaderSize: (Number, default: 8129) The maximum size of response headers
  • sendServerVersion: (boolean, default: false) Includes the Jetty server version in responses
  • sendDateHeader: (boolean, default: true) Enables/disables Date header in responses
  • secureScheme: (String, default: "https") Defines the URI scheme used for confidential and integral redirections
  • verbose: (boolean, default: false) Dump the SSL configuration at startup
  • keyStore: (String) The path to the key store
  • keyStoreType: (String, default: "JKS") The type of keystore
  • keyStorePassword: (String) The key store password
  • keyManagerPassword: (String) The key manager password
  • trustStore: (String, default: options.keyStore) The path to an optional trust store
  • trustStorePassword: (String, default: options.keysStorePassword) The password of the optional trust store
  • includeCipherSuites: (Array, default: []) An array of cipher suites to enable
  • excludeCipherSuites: (Array, default: ["^SSL_.*", "^TLS_DHE_.*", "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA", "TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA"]) An array of cipher suites to disable
  • includeProtocols: (Array, default: ["TLSv1.2"]) An array containing protocols to support
  • excludeProtocols: (Array, default: null) An array of protocols to exclude
  • allowRenegotiation: (boolean, default: false) Enables TLS renegotiation

Returns

HttpServerBuilder

HttpServerBuilder.prototype. serveApplication (mountpoint, app, options)

Configures the http server to serve an application at the specified mountpoint

Parameters

String mountpoint

The mountpoint to server the application at

String|Function app

The application to server. Can be defined either as string specifying the application module to load, or as a function.

Object options

An object containing the following options:

  • security: (boolean, default: true)
  • sessions: (boolean, default: true)
  • sessionsMaxInactiveInterval: (Number, default: null)
  • cookieName: (String, default: null)
  • cookieDomain: (String, default: null) The domain of session cookies
  • cookiePath: (String, default: null) The path of session cookies
  • cookieMaxAge: (Number, default: -1) The max age of session cookies, -1 means
  • httpOnlyCookies: (boolean, default: true) Enable/disables the HttpOnly flag of session cookies
  • secureCookies: (boolean, default: false) Enable/disables the Secure flag of session cookies
  • sameSiteCookies: (String, default: null) Sets the SameSite flag of session cookies. Possible values: "lax" (default of modern Browsers), "strict" or "none"
  • statistics: (boolean, default: false) Enable request statistics
  • virtualHosts: (String|Array) Virtual host(s) under which this application should be reachable

Returns

HttpServerBuilder

HttpServerBuilder.prototype. serveStatic (mountpoint, directory, options)

Configures the http server to serve static files at the specified mountpoint

Parameters

String mountpoint

The mountpoint to server the static files at

String directory

The directory containing the static files

Object options

An object containing the following options:

  • acceptRanges: (boolean, default: false) Enables range requests
  • allowDirectoryListing: (boolean, default: false) Enables directory listing
  • gzip: (boolean, default: false) Enables gzip compression
  • stylesheet: (String, default: null) The location to an optional stylesheet
  • etags: (boolean, default: true) Enables/disables ETag generation for static files
  • maxCacheSize: (Number, default: 0) The maximum total size of the cache (0 meaning no cache at all)
  • maxCachedFileSize: (Number, default: 0) The maximum size of a file to cache
  • maxCachedFiles: (Number, default: 0) The maximum number of files to cache
  • cacheControl: (String, default: null) If set, all files are served with this cache-control response header
  • gzipExtensions: (String, default: null) Other file extensions that signify that a file is already compressed, eg. ".svgz"

Returns

HttpServerBuilder

HttpServerBuilder.prototype. start ()

Starts the http server

Returns

HttpServerBuilder