Sha256: d701984e352e08eec88782ca37ad6e294daa8d0f0ec47ff50c869e8e75be0d5b

Contents?: true

Size: 522 Bytes

Versions: 2

Compression:

Stored size: 522 Bytes

Contents

require 'rack/manifest/version'
require 'yaml'
require 'json'

module Rack
  class Manifest
    def initialize(app)
      @app = app
    end

    def call(env)
      status, headers, body = @app.call(env)
      if env[PATH_INFO] == '/manifest.json'
        manifest = YAML.load_file('./config/manifest.yml')
        json = JSON.generate(manifest)
        [
          200, 
          {'Content-Type' => 'application/json'},
          [json]
        ]
      else
        [status, headers, body]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rack-manifest-0.1.1 lib/rack/manifest.rb
rack-manifest-0.1.0 lib/rack/manifest.rb