mirror of
				https://gitea.invidious.io/iv-org/shard-kemal.git
				synced 2024-08-15 00:53:36 +00:00 
			
		
		
		
	Update kemal.cr
This commit is contained in:
		
							parent
							
								
									17f944ef9d
								
							
						
					
					
						commit
						fdf38b23c8
					
				
					 3 changed files with 43 additions and 43 deletions
				
			
		|  | @ -1,40 +1,40 @@ | ||||||
| require "./spec_helper" | # require "./spec_helper" | ||||||
| 
 | # | ||||||
| macro render_with_base_and_layout(filename) | # macro render_with_base_and_layout(filename) | ||||||
|   render "spec/asset/#{{{filename}}}", "spec/asset/layout.ecr" | #   render "spec/asset/#{{{filename}}}", "spec/asset/layout.ecr" | ||||||
| end | # end | ||||||
| 
 | # | ||||||
| describe "Views" do | # describe "Views" do | ||||||
|   # it "renders file" do | #   it "renders file" do | ||||||
|   #   kemal = Kemal::Handler.new | #     kemal = Kemal::Handler.new | ||||||
|   #   kemal.add_route "GET", "/view/:name" do |env| | #     kemal.add_route "GET", "/view/:name" do |env| | ||||||
|   #     render "spec/asset/hello.ecr" | #       render "spec/asset/hello.ecr" | ||||||
|   #   end | #     end | ||||||
|   #   request = HTTP::Request.new("GET", "/view/world") | #     request = HTTP::Request.new("GET", "/view/world") | ||||||
|   #   io_with_context = create_request_and_return_io(kemal, request) | #     io_with_context = create_request_and_return_io(kemal, request) | ||||||
|   #   client_response = HTTP::Client::Response.from_io(io_with_context, decompress: false) | #     client_response = HTTP::Client::Response.from_io(io_with_context, decompress: false) | ||||||
|   #   client_response.body.should contain("Hello world") | #     client_response.body.should contain("Hello world") | ||||||
|   # end | #   end | ||||||
| 
 | # | ||||||
|   # it "renders file with dynamic variables" do | #   it "renders file with dynamic variables" do | ||||||
|   #   kemal = Kemal::Handler.new | #     kemal = Kemal::Handler.new | ||||||
|   #   kemal.add_route "GET", "/view/:name" do |env| | #     kemal.add_route "GET", "/view/:name" do |env| | ||||||
|   #     render_with_base_and_layout "hello.ecr" | #       render_with_base_and_layout "hello.ecr" | ||||||
|   #   end | #     end | ||||||
|   #   request = HTTP::Request.new("GET", "/view/world") | #     request = HTTP::Request.new("GET", "/view/world") | ||||||
|   #   io_with_context = create_request_and_return_io(kemal, request) | #     io_with_context = create_request_and_return_io(kemal, request) | ||||||
|   #   client_response = HTTP::Client::Response.from_io(io_with_context, decompress: false) | #     client_response = HTTP::Client::Response.from_io(io_with_context, decompress: false) | ||||||
|   #   client_response.body.should contain("Hello world") | #     client_response.body.should contain("Hello world") | ||||||
|   # end | #   end | ||||||
|   # | # | ||||||
|   # it "renders layout" do | #   it "renders layout" do | ||||||
|   #   kemal = Kemal::Handler.new | #     kemal = Kemal::Handler.new | ||||||
|   #   kemal.add_route "GET", "/view/:name" do |env| | #     kemal.add_route "GET", "/view/:name" do |env| | ||||||
|   #     render "spec/asset/hello.ecr", "spec/asset/layout.ecr" | #       render "spec/asset/hello.ecr", "spec/asset/layout.ecr" | ||||||
|   #   end | #     end | ||||||
|   #   request = HTTP::Request.new("GET", "/view/world") | #     request = HTTP::Request.new("GET", "/view/world") | ||||||
|   #   io_with_context = create_request_and_return_io(kemal, request) | #     io_with_context = create_request_and_return_io(kemal, request) | ||||||
|   #   client_response = HTTP::Client::Response.from_io(io_with_context, decompress: false) | #     client_response = HTTP::Client::Response.from_io(io_with_context, decompress: false) | ||||||
|   #   client_response.body.should contain("<html>Hello world") | #     client_response.body.should contain("<html>Hello world") | ||||||
|   # end | #   end | ||||||
| end | # end | ||||||
|  |  | ||||||
|  | @ -28,7 +28,7 @@ at_exit do | ||||||
|   get "/__kemal__/:image" do |env| |   get "/__kemal__/:image" do |env| | ||||||
|     image = env.params["image"] |     image = env.params["image"] | ||||||
|     file_path = File.expand_path("libs/kemal/images/#{image}", Dir.current) |     file_path = File.expand_path("libs/kemal/images/#{image}", Dir.current) | ||||||
|     env.add_header "Content-Type", "application/octet-stream" |     env.response.headers.add "Content-Type", "application/octet-stream" | ||||||
|     File.read(file_path) if File.exists? file_path |     File.read(file_path) if File.exists? file_path | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| class Kemal::StaticFileHandler < HTTP::StaticFileHandler | class Kemal::StaticFileHandler < HTTP::StaticFileHandler | ||||||
|   def call(request) |   def call(context) | ||||||
|     return call_next(request) if request.path.not_nil! == "/" |     return call_next(context) if context.request.path.not_nil! == "/" | ||||||
|     super |     super | ||||||
|   end |   end | ||||||
| end | end | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue