mirror of
				https://gitea.invidious.io/iv-org/shard-kemal.git
				synced 2024-08-15 00:53:36 +00:00 
			
		
		
		
	Updated to Crystal 0.5.2
This commit is contained in:
		
							parent
							
								
									889debfd59
								
							
						
					
					
						commit
						35a0eac2e9
					
				
					 2 changed files with 7 additions and 5 deletions
				
			
		|  | @ -1,4 +1,4 @@ | |||
| require "net/http" | ||||
| require "net/http/**" | ||||
| 
 | ||||
| class Frank::Handler < HTTP::Handler | ||||
|   INSTANCE = new | ||||
|  | @ -21,14 +21,14 @@ class Frank::Handler < HTTP::Handler | |||
|     @routes.each do |route| | ||||
|       params = route.match(request.method, components) | ||||
|       if params | ||||
|         frank_request = Request.new(params) | ||||
|         frank_request = Request.new(request, params) | ||||
|         context = Context.new(frank_request) | ||||
|         begin | ||||
|           body = route.handler.call(context).to_s | ||||
|           content_type = context.response?.try(&.content_type) || "text/plain" | ||||
|           return HTTP::Response.new("HTTP/1.1", 200, "OK", {"Content-Type" => content_type}, body) | ||||
|           return HTTP::Response.ok(content_type, body) | ||||
|         rescue ex | ||||
|           return HTTP::Response.new("HTTP/1.1", 500, "Internal Server Error", {"Content-Type" => "text/plain"}, ex.to_s) | ||||
|           return HTTP::Response.error("text/plain", ex.to_s) | ||||
|         end | ||||
|       end | ||||
|     end | ||||
|  |  | |||
|  | @ -1,6 +1,8 @@ | |||
| class Frank::Request | ||||
|   getter params | ||||
| 
 | ||||
|   def initialize(@params) | ||||
|   def initialize(@request, @params) | ||||
|   end | ||||
| 
 | ||||
|   delegate body, @request | ||||
| end | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue