Sha256: 6ea21e7ab42544390aeea84affdb2dbeba4541e2fff636f2388eeb71e86fe55f

Contents?: true

Size: 1.04 KB

Versions: 21

Compression:

Stored size: 1.04 KB

Contents

# -*- encoding: binary -*-
module Rainbows

# 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"
#

class ServerToken < Struct.new(:app, :token)

  # :stopdoc:
  #
  # Freeze constants as they're slightly faster when setting hashes
  SERVER = "Server".freeze

  def initialize(app, token = Const::RACK_DEFAULTS['SERVER_SOFTWARE'])
    super
  end

  def call(env)
    status, headers, body = app.call(env)
    headers = Rack::Utils::HeaderHash.new(headers) unless Hash === headers
    headers[SERVER] = token
    [ status, headers, body ]
  end
  # :startdoc:
end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
rainbows-4.7.0 lib/rainbows/server_token.rb
rainbows-4.6.2 lib/rainbows/server_token.rb
rainbows-4.6.1 lib/rainbows/server_token.rb
rainbows-4.6.0.4.g4108 lib/rainbows/server_token.rb
rainbows-4.6.0 lib/rainbows/server_token.rb
rainbows-4.5.0 lib/rainbows/server_token.rb
rainbows-4.4.3 lib/rainbows/server_token.rb
rainbows-4.4.2 lib/rainbows/server_token.rb
rainbows-4.4.1.1.gd5c8c lib/rainbows/server_token.rb
rainbows-4.4.1 lib/rainbows/server_token.rb
rainbows-4.4.0 lib/rainbows/server_token.rb
rainbows-4.3.1 lib/rainbows/server_token.rb
rainbows-4.3.0 lib/rainbows/server_token.rb
rainbows-4.2.0 lib/rainbows/server_token.rb
rainbows-4.1.0 lib/rainbows/server_token.rb
rainbows-4.0.0 lib/rainbows/server_token.rb
rainbows-3.4.0 lib/rainbows/server_token.rb
rainbows-3.3.0 lib/rainbows/server_token.rb
rainbows-3.2.0 lib/rainbows/server_token.rb
rainbows-3.1.0 lib/rainbows/server_token.rb