Created
March 18, 2016 03:39
-
-
Save yuroyoro/3302f062185e9366ab53 to your computer and use it in GitHub Desktop.
任意のassetsのレスポンスヘッダにService-Worker-Allowdヘッダを追加するRack Middleware
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RackSwHeader | |
def initialize(app, config = []) | |
@app = app | |
@config = config | |
end | |
def call(env) | |
status, headers, body = @app.call env | |
path = env["PATH_INFO"] | |
@config.each do |entry| | |
next unless path == entry[:path] | |
headers["Service-Worker-Allowed"] = entry[:scope] | |
end | |
[status, headers, body] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment