mirror of
				https://gitea.invidious.io/iv-org/shard-kemal.git
				synced 2024-08-15 00:53:36 +00:00 
			
		
		
		
	Added headers to context
This commit is contained in:
		
							parent
							
								
									5892d900ff
								
							
						
					
					
						commit
						ffdaecace4
					
				
					 2 changed files with 17 additions and 0 deletions
				
			
		|  | @ -20,4 +20,17 @@ describe "Context" do | |||
|     response = kemal.call(request) | ||||
|     response.headers["Content-Type"].should eq("application/json") | ||||
|   end | ||||
| 
 | ||||
|   it "parses headers" do | ||||
|     kemal = Kemal::Handler.new | ||||
|     kemal.add_route "GET", "/" do |env| | ||||
|       name = env.headers["name"] | ||||
|       "Hello #{name}" | ||||
|     end | ||||
|     headers = HTTP::Headers.new | ||||
|     headers["Name"] = "kemal" | ||||
|     request = HTTP::Request.new("GET", "/", headers) | ||||
|     response = kemal.call(request) | ||||
|     response.body.should eq "Hello kemal" | ||||
|   end | ||||
| end | ||||
|  |  | |||
|  | @ -9,6 +9,10 @@ class Kemal::Context | |||
|     @content_type = "text/html" | ||||
|   end | ||||
| 
 | ||||
|   def headers | ||||
|     request.headers | ||||
|   end | ||||
| 
 | ||||
|   def set_content_type(content_type) | ||||
|     @content_type = content_type | ||||
|   end | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue