Class: RailsMarkup::CorsServlet

Inherits:
WEBrick::HTTPServlet::AbstractServlet
  • Object
show all
Defined in:
lib/rails_markup/http_server.rb

Overview

Single servlet handling all routes with proper CORS support. WEBrick dispatches do_GET, do_POST, do_OPTIONS to us directly.

Instance Method Summary collapse

Constructor Details

#initialize(server, store) ⇒ CorsServlet

Returns a new instance of CorsServlet.



42
43
44
45
# File 'lib/rails_markup/http_server.rb', line 42

def initialize(server, store)
  super(server)
  @store = store
end

Instance Method Details

#do_GET(req, res) ⇒ Object



52
53
54
55
# File 'lib/rails_markup/http_server.rb', line 52

def do_GET(req, res)
  cors(res)
  route(req, res)
end

#do_OPTIONS(req, res) ⇒ Object



47
48
49
50
# File 'lib/rails_markup/http_server.rb', line 47

def do_OPTIONS(req, res)
  cors(res)
  res.status = 204
end

#do_POST(req, res) ⇒ Object



57
58
59
60
# File 'lib/rails_markup/http_server.rb', line 57

def do_POST(req, res)
  cors(res)
  route(req, res)
end