Class: Aspera::WebAuth::Servlet

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

Overview

servlet called on callback: it records the callback request

Instance Method Summary collapse

Constructor Details

#initialize(server, web_auth) ⇒ Servlet

Returns a new instance of Servlet.

Parameters:

  • server (WEBrick::HTTPServer) —

    the HTTP server instance

  • web_auth (Server) —

    the Server instance to record the callback



13
14
15
16
17
# File 'lib/aspera/web_auth/server.rb', line 13

def initialize(server, web_auth)
  Log.log.debug('Servlet initialize')
  super(server)
  @web_auth = web_auth
end

Instance Method Details

#service(request, response) ⇒ Object

called on request



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/aspera/web_auth/server.rb', line 21

def service(request, response)
  Log.log.debug { "received request from browser #{request.request_method} #{request.path}" }
  Aspera.assert_values(request.request_method, ['GET'], type: WEBrick::HTTPStatus::MethodNotAllowed) { "Unsupported method: #{req.request_method}" }
  Aspera.assert_values(request.path, ['/'], type: WEBrick::HTTPStatus::NotFound) { "Unsupported path: #{req.request_method}" }
  # response to browser
  response.status = 200
  response.content_type = 'text/html'
  response.body = File.read("#{__dir__}/index.html").gsub('__ADD_INFO__', @web_auth.info_html)
  # continue internal processing
  @web_auth.signal_request(request)
  nil
end