mirror of
				https://gitea.invidious.io/iv-org/shard-kemal.git
				synced 2024-08-15 00:53:36 +00:00 
			
		
		
		
	Update built-in exception route handler
This commit is contained in:
		
							parent
							
								
									02af920a0f
								
							
						
					
					
						commit
						94a73e9ade
					
				
					 2 changed files with 8 additions and 3 deletions
				
			
		|  | @ -1,7 +1,7 @@ | |||
| require "./spec_helper" | ||||
| 
 | ||||
| describe "Context" do | ||||
|   it "sets content type" do | ||||
|   it "has a default content type" do | ||||
|     kemal = Kemal::Handler.new | ||||
|     kemal.add_route "GET", "/" do |env| | ||||
|       "Hello" | ||||
|  |  | |||
|  | @ -28,8 +28,13 @@ at_exit do | |||
|   get "/__kemal__/:image" do |env| | ||||
|     image = env.params["image"] | ||||
|     file_path = File.expand_path("libs/kemal/images/#{image}", Dir.current) | ||||
|     env.response.headers.add "Content-Type", "application/octet-stream" | ||||
|     File.read(file_path) if File.exists? file_path | ||||
|     if File.exists? file_path | ||||
|       env.response.headers.add "Content-Type", "application/octet-stream" | ||||
|       env.response.content_length = File.size(file_path) | ||||
|       File.open(file_path) do |file| | ||||
|         IO.copy(file, env.response) | ||||
|       end | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|   server.listen | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue