mirror of
				https://gitea.invidious.io/iv-org/shard-kemal.git
				synced 2024-08-15 00:53:36 +00:00 
			
		
		
		
	Update middlewares doc
This commit is contained in:
		
							parent
							
								
									24e2647ed7
								
							
						
					
					
						commit
						a36596d332
					
				
					 1 changed files with 23 additions and 1 deletions
				
			
		|  | @ -1,6 +1,28 @@ | ||||||
| # Middlewares | # Middlewares | ||||||
| 
 | 
 | ||||||
| You can create your own middlewares by inheriting from ```HTTP::Handler``` | ## Built-in Middlewares | ||||||
|  | 
 | ||||||
|  | Kemal has built-in middlewares for common use cases. | ||||||
|  | 
 | ||||||
|  | ### HTTP Basic Authorization | ||||||
|  | 
 | ||||||
|  | This middleware let's you add HTTP Basic Authorization support to your Kemal application. | ||||||
|  | To increase easy of use you can use this middleware with `basic_auth` macro like below. | ||||||
|  | 
 | ||||||
|  | ```crystal | ||||||
|  | require "kemal" | ||||||
|  | 
 | ||||||
|  | basic_auth "username", "password" | ||||||
|  | 
 | ||||||
|  | get "/" do | ||||||
|  |   "This won't render without correct username and password." | ||||||
|  | end | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | ## Custom middlewares | ||||||
|  | 
 | ||||||
|  | You can create your own middleware by inheriting from ```HTTP::Handler``` | ||||||
| 
 | 
 | ||||||
| ```crystal | ```crystal | ||||||
| class CustomHandler < HTTP::Handler | class CustomHandler < HTTP::Handler | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue