Class: YARD::Server::WebrickServlet

Inherits:
WEBrick::HTTPServlet::AbstractServlet
  • Object
show all
Defined in:
lib/yard/server/webrick_adapter.rb

Overview

The main WEBrick servlet implementation, accepting only GET requests.

Since:

  • 0.6.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server, adapter) ⇒ WebrickServlet

Returns a new instance of WebrickServlet.

Since:

  • 0.6.0



23
24
25
26
# File 'lib/yard/server/webrick_adapter.rb', line 23

def initialize(server, adapter)
  super
  self.adapter = adapter
end

Instance Attribute Details

#adapterObject

Since:

  • 0.6.0



21
22
23
# File 'lib/yard/server/webrick_adapter.rb', line 21

def adapter
  @adapter
end

Instance Method Details

#do_GET(request, response) ⇒ Object

Since:

  • 0.6.0



29
30
31
32
33
34
35
36
# File 'lib/yard/server/webrick_adapter.rb', line 29

def do_GET(request, response) # rubocop:disable Style/MethodName
  status, headers, body = *adapter.router.call(request)
  response.status = status
  response.body = body.is_a?(Array) ? body[0] : body
  headers.each do |key, value|
    response[key] = value
  end
end