Class: CSGOLytics::HTTPServlet

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

Instance Method Summary collapse

Constructor Details

#initialize(server, backend) ⇒ HTTPServlet

Returns a new instance of HTTPServlet.



5
6
7
8
# File 'lib/csgolytics/http_server.rb', line 5

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

Instance Method Details

#do_POST(request, response) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/csgolytics/http_server.rb', line 10

def do_POST (request, response)
  if request.path == "/api/v1/insert_logline"
    @backend.insert_logline request.body.force_encoding("utf-8")
    response.status = 201
    response.body = "ok"
    response.content_type = "text/plan"
    return
   end

  response.status = 404
  response.body = "not found"
  response.content_type = "text/plan"
end