mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Introduce Kemal::InitHandler to initialize HTTP::Server::Context with defaults
This commit is contained in:
parent
725e051723
commit
09d9e708f1
10 changed files with 48 additions and 40 deletions
21
spec/init_handler_spec.cr
Normal file
21
spec/init_handler_spec.cr
Normal file
|
@ -0,0 +1,21 @@
|
|||
require "./spec_helper"
|
||||
|
||||
describe "Kemal::InitHandler" do
|
||||
it "initializes context with Content-Type: text/html" do
|
||||
request = HTTP::Request.new("GET", "/")
|
||||
io = MemoryIO.new
|
||||
response = HTTP::Server::Response.new(io)
|
||||
context = HTTP::Server::Context.new(request, response)
|
||||
Kemal::InitHandler::INSTANCE.call(context)
|
||||
context.response.headers["Content-Type"].should eq "text/html"
|
||||
end
|
||||
|
||||
it "initializes context with X-Powered-By: Kemal" do
|
||||
request = HTTP::Request.new("GET", "/")
|
||||
io = MemoryIO.new
|
||||
response = HTTP::Server::Response.new(io)
|
||||
context = HTTP::Server::Context.new(request, response)
|
||||
Kemal::InitHandler::INSTANCE.call(context)
|
||||
context.response.headers["X-Powered-By"].should eq "Kemal"
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue