mirror of
				https://gitea.invidious.io/iv-org/shard-kemal.git
				synced 2024-08-15 00:53:36 +00:00 
			
		
		
		
	
							parent
							
								
									8cf3f67594
								
							
						
					
					
						commit
						30bdcc9759
					
				
					 2 changed files with 12 additions and 1 deletions
				
			
		|  | @ -10,6 +10,15 @@ describe "Kemal::RouteHandler" do | |||
|     client_response.body.should eq("hello") | ||||
|   end | ||||
| 
 | ||||
|   it "routes should only return strings" do | ||||
|     get "/" do | ||||
|       100 | ||||
|     end | ||||
|     request = HTTP::Request.new("GET", "/") | ||||
|     client_response = call_request_on_app(request) | ||||
|     client_response.body.should eq("") | ||||
|   end | ||||
| 
 | ||||
|   it "routes request with query string" do | ||||
|     get "/" do |env| | ||||
|       "hello #{env.params.query["message"]}" | ||||
|  | @ -155,4 +164,5 @@ describe "Kemal::RouteHandler" do | |||
|     client_response.status_code.should eq(302) | ||||
|     client_response.headers.has_key?("Location").should eq(true) | ||||
|   end | ||||
|    | ||||
| end | ||||
|  |  | |||
|  | @ -8,7 +8,8 @@ module Kemal | |||
| 
 | ||||
|     def initialize(@method : String, @path : String, &handler : HTTP::Server::Context -> _) | ||||
|       @handler = ->(context : HTTP::Server::Context) do | ||||
|         handler.call(context).to_s | ||||
|         output = handler.call(context) | ||||
|         output.is_a?(String) ? output : "" | ||||
|       end | ||||
|     end | ||||
|   end | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue