-
-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathfalcon.rb
22 lines (16 loc) · 956 Bytes
/
falcon.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2017-2025, by Samuel Williams.
# Copyright, 2019, by Bryan Powell.
require "rack/handler"
require_relative "../../falcon/rackup/handler"
# Generally speaking, you should not require this file directly, or assume the existance of the `Rack::Handler::Falcon` constant. Instead, use `Rack::Handler.get(:falcon)` to load and access the handler.
module Rack
module Handler
# Rack (v2) expects the constant to be in the `Rack::Handler` namespace, so we define a new handler class in the `Rack::Handler` namespace that inherits from `Falcon::Rackup::Handler`.
class Falcon < ::Falcon::Rackup::Handler
end
# Rack (v2) expects a string for the handler constant name. `Falcon.to_s` returns a more human friendly name, so we explicitly pass `Falcon.name` to `register` to ensure Rack can find the handler using the registered name.
register :falcon, Falcon.name
end
end