Fork me on GitHub

Module ringo/httpserver

Class Server

Instance Methods


Server (options)

Create a Jetty HTTP server with the given options. The options may either define properties to be used with the default jetty.xml, or define a custom configuration file.

Parameters

Object options A javascript object with any of the following properties, with the default value in parentheses:
  • jettyConfig ('config/jetty.xml')
  • port (8080)
  • host (undefined)
For convenience, the constructor supports the definition of a JSGI and static resource mapping in the config object using the following properties:
  • virtualHost (undefined)
  • mountpoint ('/')
  • staticDir ('static')
  • staticMountpoint ('/static')
  • moduleName ('config')
  • functionName ('app')

Server.prototype.addApplication (path, vhosts, app, engine)

Map a request path to a JSGI application. Map a request path to a directory containing static resources.

Parameters

string path a request path such as "/foo/bar" or "/"
string|array vhosts optional single or multiple virtual host names. A virtual host may start with a "*." wildcard.
function|object app a JSGI application, either as a function or an object with properties moduleName and functionName defining the application.
{ moduleName: 'config', functionName: 'app' }
RhinoEngine engine optional RhinoEngine instance for multi-engine setups

Server.prototype.addServlet (path, vhosts, servlet, options)

Map a request path to a servlet.

Parameters

string path a request path such as "/foo/bar" or "/"
string|array vhosts optional single or multiple virtual host names. A virtual host may start with a "*." wildcard.
Servlet servlet a java object implementing the javax.servlet.Servlet interface.
object options object. Supports the following boolean flags: - sessions - enable session support - security - enable security support - redirect - enable redirects from /path to /path/

Server.prototype.addStaticResources (path, vhosts, dir)

Map a request path to a directory containing static resources.

Parameters

string path a request path such as "/foo/bar" or "/"
string|array vhosts optional single or multiple virtual host names A virtual host may start with a "*." wildcard.
string dir the directory from which to serve static resources

Server.prototype.destroy ()

Destroy the HTTP server, freeing its resources.


Server.prototype.getJetty ()

Get the Jetty server instance

Returns

the Jetty Server instance

Server.prototype.isRunning ()

Checks whether this server is currently running.

Returns

true if the server is running, false otherwise.

Server.prototype.start ()

Start the HTTP server.


Server.prototype.stop ()

Stop the HTTP server.