123456789_123456789_123456789_123456789_123456789_

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:
Instance Chain:
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

AbstractServlet - Inherited

.get_instance

Factory for servlet instances that will handle a request from server using options from the mount point.

.new

Initializes a new servlet for server using options which are stored as-is in @options.

Instance Method Summary

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 do_ method based on req if such a method is available.

#redirect_to_directory_uri

Redirects to a path ending in /.

Constructor Details

.new(proc) ⇒ ProcHandler

[ GitHub ]

  
# 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.

[ GitHub ]

  
# 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, *options)
  self
end