Fork me on GitHub

Module ringo/httpserver

Class Server

Instance Methods


Server (config)

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

Parameters

Object config A javascript object with any of the following properties, with the default value in parentheses:
  • configFile ('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.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.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.