Class: WEBrick::HTTPServlet::ProcHandler
Do not use. This class is for internal use only.
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
AbstractServlet
|
|
Instance Chain:
self,
AbstractServlet
|
|
Inherits: |
WEBrick::HTTPServlet::AbstractServlet
|
Defined in: | lib/webrick/httpservlet/prochandler.rb |
Overview
Mounts a proc at a path that accepts a request and response.
Instead of mounting this servlet with WEBrick::HTTPServer#mount use WEBrick::HTTPServer#mount_proc:
server.mount_proc '/' do |req, res|
res.body = 'it worked!'
res.status = 200
end
Class Method Summary
- .new(proc) ⇒ ProcHandler constructor
AbstractServlet - Inherited
.get_instance | Factory for servlet instances that will handle a request from |
.new | Initializes a new servlet for |
Instance Method Summary
- #do_GET(request, response) (also: #do_POST)
-
#do_POST(request, response)
Alias for #do_GET.
- #get_instance(server, *options)
AbstractServlet - Inherited
#do_GET | Raises a NotFound exception. |
#do_HEAD | Dispatches to do_GET. |
#do_OPTIONS | Returns the allowed HTTP request methods. |
#service | Dispatches to a |
#redirect_to_directory_uri | Redirects to a path ending in /. |
Constructor Details
.new(proc) ⇒ ProcHandler
# File 'lib/webrick/httpservlet/prochandler.rb', line 34
def initialize(proc) @proc = proc end
Instance Method Details
#do_GET(request, response) Also known as: #do_POST
[ GitHub ]# File 'lib/webrick/httpservlet/prochandler.rb', line 38
def do_GET(request, response) @proc.call(request, response) end
#do_POST(request, response)
Alias for #do_GET.
# File 'lib/webrick/httpservlet/prochandler.rb', line 42
alias do_POST do_GET
#get_instance(server, *options)
[ GitHub ]# File 'lib/webrick/httpservlet/prochandler.rb', line 30
def get_instance(server, * ) self end