mirror of
				https://gitea.invidious.io/iv-org/shard-kemal.git
				synced 2024-08-15 00:53:36 +00:00 
			
		
		
		
	Split helpers.cr into helpers/macros.cr and helpers/helpers.cr
This commit is contained in:
		
							parent
							
								
									daac09a859
								
							
						
					
					
						commit
						f3175bdb72
					
				
					 3 changed files with 42 additions and 42 deletions
				
			
		|  | @ -1,4 +1,5 @@ | |||
| require "./kemal/*" | ||||
| require "./kemal/helpers/*" | ||||
| require "./kemal/middleware/*" | ||||
| 
 | ||||
| module Kemal | ||||
|  |  | |||
							
								
								
									
										41
									
								
								src/kemal/helpers/helpers.cr
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								src/kemal/helpers/helpers.cr
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,41 @@ | |||
| # Adds given HTTP::Handler+ to handlers. | ||||
| def add_handler(handler) | ||||
|   Kemal.config.add_handler handler | ||||
| end | ||||
| 
 | ||||
| # Uses Kemal::Middleware::HTTPBasicAuth to easily add HTTP Basic Auth support. | ||||
| def basic_auth(username, password) | ||||
|   auth_handler = Kemal::Middleware::HTTPBasicAuth.new(username, password) | ||||
|   add_handler auth_handler | ||||
| end | ||||
| 
 | ||||
| # Sets public folder from which the static assets will be served. | ||||
| # By default this is `/public` not `src/public`. | ||||
| def public_folder(path) | ||||
|   Kemal.config.public_folder = path | ||||
| end | ||||
| 
 | ||||
| # Logs to output stream. | ||||
| # development: STDOUT in | ||||
| # production: kemal.log | ||||
| def log(message) | ||||
|   Kemal.config.logger.write "#{message}\n" | ||||
| end | ||||
| 
 | ||||
| # Enables / Disables logging | ||||
| def logging(status) | ||||
|   Kemal.config.logging = status | ||||
| end | ||||
| 
 | ||||
| def logger(logger) | ||||
|   Kemal.config.logger = logger | ||||
|   Kemal.config.add_handler logger | ||||
| end | ||||
| 
 | ||||
| def serve_static(status) | ||||
|   Kemal.config.serve_static = status | ||||
| end | ||||
| 
 | ||||
| def headers(env, additional_headers) | ||||
|   env.response.headers.merge!(additional_headers) | ||||
| end | ||||
|  | @ -58,45 +58,3 @@ macro return_with(env, status_code = 200, response = "") | |||
|   {{env}}.response.print {{response}} | ||||
|   next | ||||
| end | ||||
| 
 | ||||
| # Adds given HTTP::Handler+ to handlers. | ||||
| def add_handler(handler) | ||||
|   Kemal.config.add_handler handler | ||||
| end | ||||
| 
 | ||||
| # Uses Kemal::Middleware::HTTPBasicAuth to easily add HTTP Basic Auth support. | ||||
| def basic_auth(username, password) | ||||
|   auth_handler = Kemal::Middleware::HTTPBasicAuth.new(username, password) | ||||
|   add_handler auth_handler | ||||
| end | ||||
| 
 | ||||
| # Sets public folder from which the static assets will be served. | ||||
| # By default this is `/public` not `src/public`. | ||||
| def public_folder(path) | ||||
|   Kemal.config.public_folder = path | ||||
| end | ||||
| 
 | ||||
| # Logs to output stream. | ||||
| # development: STDOUT in | ||||
| # production: kemal.log | ||||
| def log(message) | ||||
|   Kemal.config.logger.write "#{message}\n" | ||||
| end | ||||
| 
 | ||||
| # Enables / Disables logging | ||||
| def logging(status) | ||||
|   Kemal.config.logging = status | ||||
| end | ||||
| 
 | ||||
| def logger(logger) | ||||
|   Kemal.config.logger = logger | ||||
|   Kemal.config.add_handler logger | ||||
| end | ||||
| 
 | ||||
| def serve_static(status) | ||||
|   Kemal.config.serve_static = status | ||||
| end | ||||
| 
 | ||||
| def headers(env, additional_headers) | ||||
|   env.response.headers.merge!(additional_headers) | ||||
| end | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue