AbstractServlet
allows HTTP server modules to be reused across multiple servers and allows encapsulation of functionality.
By default a servlet will respond to GET, HEAD (through an alias to GET) and OPTIONS requests.
By default a new servlet is initialized for every request. A servlet instance can be reused by overriding ::get_instance
in the AbstractServlet
subclass.
class Simple < WEBrick::HTTPServlet::AbstractServlet def do_GET request, response status, content_type, body = do_stuff_with request response.status = status response['Content-Type'] = content_type response.body = body end def do_stuff_with request return 200, 'text/plain', 'you got a page' end end
This servlet can be mounted on a server at a given path:
server.mount '/simple', Simple
Servlets can be configured via initialize. The first argument is the HTTP server the servlet is being initialized for.
class Configurable < Simple def initialize server, color, size super server @color = color @size = size end def do_stuff_with request content = "<p " \ %q{style="color: #{@color}; font-size: #{@size}"} \ ">Hello, World!" return 200, "text/html", content end end
This servlet must be provided two arguments at mount time:
server.mount '/configurable', Configurable, 'red', '2em'
ERBHandler
evaluates an ERB
file and returns the result. This handler is automatically used if there are .rhtml files in a directory served by the FileHandler
.
ERBHandler
supports GET and POST methods.
The ERB
file is evaluated with the local variables servlet_request
and servlet_response
which are a WEBrick::HTTPRequest
and WEBrick::HTTPResponse
respectively.
Example .rhtml file:
Request to <%= servlet_request.request_uri %> Query params <%= servlet_request.query.inspect %>
Class
used to manage timeout handlers across multiple threads.
Timeout
handlers should be managed by using the class methods which are synchronized.
id = TimeoutHandler.register(10, Timeout::Error) begin sleep 20 puts 'foo' ensure TimeoutHandler.cancel(id) end
will raise Timeout::Error
id = TimeoutHandler.register(10, Timeout::Error) begin sleep 5 puts 'foo' ensure TimeoutHandler.cancel(id) end
will print ‘foo’
Patterns used to parse URI’s
User database mixin for HTTPAuth
. This mixin dispatches user record access to the underlying auth_type
for this database.
Raised when a lockfile cannot be parsed
An error caused by conflicts in version
Provides information about specifcations and dependencies to the resolver, allowing the {Resolver} class to remain generic while still providing power and flexibility.
This module contains the methods that users of Gem::Resolver::Molinillo
must to implement, using knowledge of their own model classes.
Extends Fiddle::Closure
to allow for building the closure in a block
Deprecated.
This class is only provided for backwards compatibility. Use OpenSSL::Cipher
.