metropolis.git  about / heads / tags
key-value store for Rack
blob 1234e82b33c2b30d276a7572e00e2c4082ce20c3 401 bytes (raw)
$ git show HEAD:lib/metropolis/suffix_mime.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
 
module Metropolis::SuffixMime
  MIME_TYPES = Rack::Mime::MIME_TYPES
  include Metropolis::Constants

  def get(key, env)
    set_mime(key, super)
  end

  def head(key, env)
    set_mime(key, super)
  end

  def set_mime(key, response)
    status, headers, _ = response
    200 == status && /(\.[^\.]+)\z/ =~ key and
      type = MIME_TYPES[$1] and headers[Content_Type] = type
    response
  end
end

git clone https://yhbt.net/metropolis.git