class VueCK::Plugin

Constants

REQUEST_MAP

Public Class Methods

new(app={}) click to toggle source
# File lib/plugin.rb, line 14
def initialize(app={})
    @app = app
end

Public Instance Methods

call(env) click to toggle source
# File lib/plugin.rb, line 18
def call(env)
    return @app.call(env) unless env["REQUEST_METHOD"] == "GET"
    path = env["PATH_INFO"]
    return @app.call(env) unless REQUEST_MAP[path]
    vueck = VueCK.new REQUEST_MAP[path][:file]
    content = vueck.serve_file
    response(content, path)
end
response(content, path) click to toggle source
# File lib/plugin.rb, line 27
def response(content, path)
    ["200", {
        "Content-Type"   => REQUEST_MAP[path][:content_type],
        "Content-Length" => content.size.to_s },
        [content]]
end