class Fluent::PluginHelper::HttpServer::Router
Public Class Methods
new(default_app = nil)
click to toggle source
# File lib/fluent/plugin_helper/http_server/router.rb, line 29 def initialize(default_app = nil) @router = { get: {}, head: {}, post: {}, put: {}, patch: {}, delete: {}, connect: {}, options: {}, trace: {} } @default_app = default_app || NotFoundApp end
Public Instance Methods
mount(method, path, app)
click to toggle source
@param method [Symbol] @param path [String] @param app [Object]
# File lib/fluent/plugin_helper/http_server/router.rb, line 37 def mount(method, path, app) if @router[method].include?(path) raise "#{path} is already mounted" end @router[method][path] = app end
route!(method, path, request)
click to toggle source
@param method [Symbol] @param path [String] @param request [Fluent::PluginHelper::HttpServer::Request]
# File lib/fluent/plugin_helper/http_server/router.rb, line 48 def route!(method, path, request) @router.fetch(method).fetch(path, @default_app).call(request) end