Sha256: 615e9195249a3dd1f6242705524ce9c6b69219317c700dd67f58ce93d8114caa

Contents?: true

Size: 1.05 KB

Versions: 13

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true
#
# prochandler.rb -- ProcHandler Class
#
# Author: IPR -- Internet Programming with Ruby -- writers
# Copyright (c) 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou
# Copyright (c) 2002 Internet Programming with Ruby writers. All rights
# reserved.
#
# $IPR: prochandler.rb,v 1.7 2002/09/21 12:23:42 gotoyuzo Exp $

require_relative 'abstract'

module WEBrick
  module HTTPServlet

    ##
    # 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 ProcHandler < AbstractServlet
      # :stopdoc:
      def get_instance(server, *options)
        self
      end

      def initialize(proc)
        @proc = proc
      end

      def do_GET(request, response)
        @proc.call(request, response)
      end

      alias do_POST do_GET
      alias do_PUT  do_GET
      # :startdoc:
    end

  end
end

Version data entries

13 entries across 13 versions & 8 rubygems

Version Path
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpservlet/prochandler.rb
webrick-1.9.1 lib/webrick/httpservlet/prochandler.rb
webrick-1.9.0 lib/webrick/httpservlet/prochandler.rb
webrick-1.8.2 lib/webrick/httpservlet/prochandler.rb
fluent-plugin-nuopenlineage-light-0.1.0 vendor/bundle/ruby/3.3.0/gems/webrick-1.8.1/lib/webrick/httpservlet/prochandler.rb
fluent-plugin-openlineage-light-0.1.4 vendor/bundle/ruby/3.3.0/gems/webrick-1.8.1/lib/webrick/httpservlet/prochandler.rb
fluent-plugin-openlineage-light-0.1.3 vendor/bundle/ruby/3.3.0/gems/webrick-1.8.1/lib/webrick/httpservlet/prochandler.rb
fluent-plugin-openlineage-0.1.0 vendor/bundle/ruby/3.3.0/gems/webrick-1.8.1/lib/webrick/httpservlet/prochandler.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/httpservlet/prochandler.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/webrick-1.8.1/lib/webrick/httpservlet/prochandler.rb
fluent-plugin-google-cloud-logging-on-prem-0.1.0 vendor/ruby/3.1.0/gems/webrick-1.8.1/lib/webrick/httpservlet/prochandler.rb
webrick-1.8.1 lib/webrick/httpservlet/prochandler.rb
webrick-1.8.0 lib/webrick/httpservlet/prochandler.rb