Sha256: af1f024eb1a1beac87897248f9a87b0eeb80f9388daec8d5265ffccf908b1fa6

Contents?: true

Size: 980 Bytes

Versions: 1

Compression:

Stored size: 980 Bytes

Contents

module VueCK
    class Plugin
        REQUEST_MAP = {
            "/vue/vue.js" => {
                file: "vue.js",
                content_type: "application/javascript"
            },
            "/vue/vue.css" => {
                file: "vue.css",
                content_type: "text/css"
            }
        }

        def initialize(app={})
            @app = app
        end
        
        def call(env)
            return 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

        def response(content, path)
            ["200", {
                "Content-Type"   => REQUEST_MAP[path][:content_type],
                "Content-Length" => content.size.to_s },
                [content]]
        end

    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vueck-1.0.2 lib/plugin.rb