Sha256: 92ad1baf31b15f4dcbf57dcabf3ba1585247a522f05c5c1515d3e0121264a7dc

Contents?: true

Size: 1.09 KB

Versions: 25

Compression:

Stored size: 1.09 KB

Contents

require 'webrick'
require 'webrick/utils'
require 'rack/handler/webrick'
module Merb
  module Rack

    class WEBrick < Merb::Rack::AbstractAdapter
      
      class << self
        # :api: private
        attr_accessor :server
      end

      # :api: plugin
      def self.new_server(port)
        options = {
          :Port        => port,
          :BindAddress => @opts[:host],
          :Logger      => Merb.logger,
          :AccessLog   => [
            [Merb.logger, ::WEBrick::AccessLog::COMMON_LOG_FORMAT],
            [Merb.logger, ::WEBrick::AccessLog::REFERER_LOG_FORMAT]
          ]
        }

        sockets = ::WEBrick::Utils.create_listeners nil, port
        @server = ::WEBrick::HTTPServer.new(options.merge(:DoNotListen => true))
        @server.listeners.replace sockets
      end

      # :api: plugin
      def self.start_server
        @server.mount("/", ::Rack::Handler::WEBrick, @opts[:app])
        @server.start
        exit(@status)
      end
      
      # :api: plugin
      def self.stop(status = 0)
        @status = status
        @server.shutdown
      end

    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
merb-core-1.1.3 lib/merb-core/rack/adapter/webrick.rb
merb-core-1.1.2 lib/merb-core/rack/adapter/webrick.rb
merb-core-1.1.1 lib/merb-core/rack/adapter/webrick.rb
merb-core-1.1.0 lib/merb-core/rack/adapter/webrick.rb
merb-core-1.1.0.rc1 lib/merb-core/rack/adapter/webrick.rb
merb-core-1.1.0.pre lib/merb-core/rack/adapter/webrick.rb
merb-core-1.0.15 lib/merb-core/rack/adapter/webrick.rb
merb-core-1.0.14 lib/merb-core/rack/adapter/webrick.rb
merb-core-1.0.13 lib/merb-core/rack/adapter/webrick.rb
merb-core-1.0.12 lib/merb-core/rack/adapter/webrick.rb
merb-core-1.0.2 lib/merb-core/rack/adapter/webrick.rb
merb-core-1.0.11 lib/merb-core/rack/adapter/webrick.rb
merb-core-1.0.10 lib/merb-core/rack/adapter/webrick.rb
merb-core-1.0.1 lib/merb-core/rack/adapter/webrick.rb
merb-core-1.0.3 lib/merb-core/rack/adapter/webrick.rb
merb-core-1.0.4 lib/merb-core/rack/adapter/webrick.rb
merb-core-1.0.5 lib/merb-core/rack/adapter/webrick.rb
merb-core-1.0.6.1 lib/merb-core/rack/adapter/webrick.rb
merb-core-1.0.6 lib/merb-core/rack/adapter/webrick.rb
merb-core-1.0.7 lib/merb-core/rack/adapter/webrick.rb