Module ringo/httpserver
A wrapper for the Jetty HTTP server.
Class Context
Instance Methods
- addServlet(servletPath, servlet, initParams)
- serveApplication(app, engine)
- serveStatic(dir)
Class Server
Instance Methods
- destroy()
- getContext(path, virtualHosts, options)
- getDefaultContext()
- getJetty()
- isRunning()
- start()
- stop()
Context.prototype.addServlet (servletPath, servlet, initParams)
Map a request path within this context to the given servlet.
Parameters
| string | servletPath | the servlet path |
| Servlet | servlet | a java object implementing the javax.servlet.Servlet interface. |
| Object | initParams | optional object containing servlet init parameters |
Context.prototype.serveApplication (app, engine)
Map this context to a JSGI application.
Parameters
| function|object | app | a JSGI application, either as a function or an object
with properties config and app defining
the application.
{ config: 'config', app: 'app' } |
| RhinoEngine | engine | optional RhinoEngine instance for multi-engine setups |
Context.prototype.serveStatic (dir)
Map this context to a directory containing static resources.
Parameters
| string | dir | the directory from which to serve static resources |
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:
|
Server.prototype.destroy ()
Destroy the HTTP server, freeing its resources.
Server.prototype.getContext (path, virtualHosts, options)
Get a servlet application context for the given path and virtual hosts, creating it if it doesn't exist.
Parameters
| string | path | the context root path such as "/" or "/app" |
| string|array | virtualHosts | optional single or multiple virtual host names. A virtual host may start with a "*." wildcard. |
| Object | options | may have the following properties: sessions: true to enable sessions for this context, false otherwise security: true to enable security for this context, false otherwise |
Returns
| a Context object |
Server.prototype.getDefaultContext ()
Get the server's default context. The default context is the context that is created when the server is created.
Returns
| the default context |
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.
