Fixes README.md
This commit is contained in:
		
							
								
								
									
										20
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								README.md
									
									
									
									
									
								
							@ -36,7 +36,7 @@ func main() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
```go
 | 
					```go
 | 
				
			||||||
func main() {
 | 
					func main() {
 | 
				
			||||||
    // Creates a gin router + logger and recovery (crash-free) middlwares
 | 
					    // Creates a gin router + logger and recovery (crash-free) middlewares
 | 
				
			||||||
    r := gin.Default()
 | 
					    r := gin.Default()
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    r.GET("/someGet", getting)
 | 
					    r.GET("/someGet", getting)
 | 
				
			||||||
@ -78,7 +78,7 @@ func main() {
 | 
				
			|||||||
        v1.POST("/read", readEndpoint)
 | 
					        v1.POST("/read", readEndpoint)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    // Simple group: v1
 | 
					    // Simple group: v2
 | 
				
			||||||
    v2 := r.Group("/v2")
 | 
					    v2 := r.Group("/v2")
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        v2.POST("/login", loginEndpoint)
 | 
					        v2.POST("/login", loginEndpoint)
 | 
				
			||||||
@ -109,27 +109,27 @@ r := gin.Default()
 | 
				
			|||||||
#### Using middlewares
 | 
					#### Using middlewares
 | 
				
			||||||
```go
 | 
					```go
 | 
				
			||||||
func main() {
 | 
					func main() {
 | 
				
			||||||
    // Creates a router without any middlware by default
 | 
					    // Creates a router without any middleware by default
 | 
				
			||||||
    r := gin.New()
 | 
					    r := gin.New()
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    // Global middlwares
 | 
					    // Global middlewares
 | 
				
			||||||
    r.Use(gin.Logger())
 | 
					    r.Use(gin.Logger())
 | 
				
			||||||
    r.Use(gin.Recovery())
 | 
					    r.Use(gin.Recovery())
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    // Per route middlwares, you can add as many as you desire.
 | 
					    // Per route middlewares, you can add as many as you desire.
 | 
				
			||||||
    r.GET("/benchmark", MyBenchLogger(), benchEndpoint)
 | 
					    r.GET("/benchmark", MyBenchLogger(), benchEndpoint)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Authorization group
 | 
					    // Authorization group
 | 
				
			||||||
    // authorized := r.Group("/", AuthRequired())
 | 
					    // authorized := r.Group("/", AuthRequired())
 | 
				
			||||||
    // exactly the same than:
 | 
					    // exactly the same than:
 | 
				
			||||||
    authorized := r.Group("/")
 | 
					    authorized := r.Group("/")
 | 
				
			||||||
    // per group middlwares! in this case we use the custom created
 | 
					    // per group middlewares! in this case we use the custom created
 | 
				
			||||||
    // AuthRequired() middlware just in the "authorized" group.
 | 
					    // AuthRequired() middleware just in the "authorized" group.
 | 
				
			||||||
    authorized.Use(AuthRequired())
 | 
					    authorized.Use(AuthRequired())
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        authorized.Use.POST("/login", loginEndpoint)
 | 
					        authorized.POST("/login", loginEndpoint)
 | 
				
			||||||
        authorized.Use.POST("/submit", submitEndpoint)
 | 
					        authorized.POST("/submit", submitEndpoint)
 | 
				
			||||||
        authorized.Use.POST("/read", readEndpoint)
 | 
					        authorized.POST("/read", readEndpoint)
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        // nested group
 | 
					        // nested group
 | 
				
			||||||
        testing := authorized.Group("testing")
 | 
					        testing := authorized.Group("testing")
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user