Class: Fluent::PluginHelper::HttpServer::App
- Inherits:
-
Object
- Object
- Fluent::PluginHelper::HttpServer::App
- Defined in:
- lib/fluent/plugin_helper/http_server/app.rb
Instance Method Summary collapse
-
#call(request) ⇒ Object
Required method by async-http.
-
#initialize(router, logger) ⇒ App
constructor
A new instance of App.
Constructor Details
#initialize(router, logger) ⇒ App
Returns a new instance of App.
25 26 27 28 |
# File 'lib/fluent/plugin_helper/http_server/app.rb', line 25 def initialize(router, logger) @logger = logger @router = router end |
Instance Method Details
#call(request) ⇒ Object
Required method by async-http
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/fluent/plugin_helper/http_server/app.rb', line 31 def call(request) method = request.method resp = case method when HttpServer::Methods::GET get(request) when HttpServer::Methods::HEAD head(request) when HttpServer::Methods::POST post(request) when HttpServer::Methods::PATCH patch(request) when HttpServer::Methods::PUT put(request) when HttpServer::Methods::DELETE delete(request) when HttpServer::Methods::OPTIONS (request) when HttpServer::Methods::CONNECT connect(request) when HttpServer::Methods::TRACE trace(request) else raise "Unknown method #{method}" end Protocol::HTTP::Response[*resp] rescue => e @logger.error(e) Protocol::HTTP::Response[500, { 'Content-Type' => 'text/plain' }, 'Internal Server Error'] end |