mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Merge pull request #165 from MGerrior/add_headers_helper_method
Add headers helper method
This commit is contained in:
commit
56067b6280
2 changed files with 21 additions and 0 deletions
|
@ -67,4 +67,21 @@ describe "Macros" do
|
|||
client_response.body.should eq("")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#headers" do
|
||||
it "can add headers" do
|
||||
get "/headers" do |env|
|
||||
env.response.headers.add "Content-Type", "image/png"
|
||||
headers env, {
|
||||
"Access-Control-Allow-Origin" => "*",
|
||||
"Content-Type" => "text/plain"
|
||||
}
|
||||
end
|
||||
|
||||
request = HTTP::Request.new("GET", "/headers")
|
||||
response = call_request_on_app(request)
|
||||
response.headers["Access-Control-Allow-Origin"].should eq("*")
|
||||
response.headers["Content-Type"].should eq("text/plain")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -57,3 +57,7 @@ end
|
|||
def serve_static(status)
|
||||
Kemal.config.serve_static = status
|
||||
end
|
||||
|
||||
def headers(env, additional_headers)
|
||||
env.response.headers.merge!(additional_headers)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue