Class: Rainbows::ServerToken
- Inherits:
-
Struct
- Object
- Struct
- Rainbows::ServerToken
- Defined in:
- lib/rainbows/server_token.rb
Overview
An optional middleware to proudly display your usage of Rainbows! in the “Server:” response header. This means you can help tell the world you’re using Rainbows! and spread fun and joy all over the Internet!
------ in your config.ru ------
require 'rainbows/server_token'
require 'rack/lobster'
use Rainbows::ServerToken
run Rack::Lobster.new
If you’re nervous about the exact version of Rainbows! you’re running, then you can actually specify anything you want:
use Rainbows::ServerToken, "netcat 1.0"
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, token = Const::RACK_DEFAULTS['SERVER_SOFTWARE']) ⇒ ServerToken
constructor
A new instance of ServerToken.
Constructor Details
#initialize(app, token = Const::RACK_DEFAULTS['SERVER_SOFTWARE']) ⇒ ServerToken
Returns a new instance of ServerToken.
22 23 24 |
# File 'lib/rainbows/server_token.rb', line 22 def initialize(app, token = Const::RACK_DEFAULTS['SERVER_SOFTWARE']) super end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app
20 21 22 |
# File 'lib/rainbows/server_token.rb', line 20 def app @app end |
#token ⇒ Object
Returns the value of attribute token
20 21 22 |
# File 'lib/rainbows/server_token.rb', line 20 def token @token end |
Instance Method Details
#call(env) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/rainbows/server_token.rb', line 26 def call(env) status, headers, body = app.call(env) headers = Rack::Utils::HeaderHash.new(headers) unless Hash === headers headers['Server'.freeze] = token [ status, headers, body ] end |