Cosmetic changes
This commit is contained in:
		
							
								
								
									
										34
									
								
								gin.go
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								gin.go
									
									
									
									
									
								
							@ -19,9 +19,24 @@ const Version = "v1.0rc2"
 | 
				
			|||||||
var default404Body = []byte("404 page not found")
 | 
					var default404Body = []byte("404 page not found")
 | 
				
			||||||
var default405Body = []byte("405 method not allowed")
 | 
					var default405Body = []byte("405 method not allowed")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type HandlerFunc func(*Context)
 | 
				
			||||||
 | 
					type HandlersChain []HandlerFunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (c HandlersChain) Last() HandlerFunc {
 | 
				
			||||||
 | 
						length := len(c)
 | 
				
			||||||
 | 
						if length > 0 {
 | 
				
			||||||
 | 
							return c[length-1]
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type (
 | 
					type (
 | 
				
			||||||
	HandlerFunc   func(*Context)
 | 
						RoutesInfo []RouteInfo
 | 
				
			||||||
	HandlersChain []HandlerFunc
 | 
						RouteInfo  struct {
 | 
				
			||||||
 | 
							Method  string
 | 
				
			||||||
 | 
							Path    string
 | 
				
			||||||
 | 
							Handler string
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Represents the web framework, it wraps the blazing fast httprouter multiplexer and a list of global middlewares.
 | 
						// Represents the web framework, it wraps the blazing fast httprouter multiplexer and a list of global middlewares.
 | 
				
			||||||
	Engine struct {
 | 
						Engine struct {
 | 
				
			||||||
@ -61,25 +76,10 @@ type (
 | 
				
			|||||||
		HandleMethodNotAllowed bool
 | 
							HandleMethodNotAllowed bool
 | 
				
			||||||
		ForwardedByClientIP    bool
 | 
							ForwardedByClientIP    bool
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
	RoutesInfo []RouteInfo
 | 
					 | 
				
			||||||
	RouteInfo  struct {
 | 
					 | 
				
			||||||
		Method  string
 | 
					 | 
				
			||||||
		Path    string
 | 
					 | 
				
			||||||
		Handler string
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var _ RoutesInterface = &Engine{}
 | 
					var _ RoutesInterface = &Engine{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c HandlersChain) Last() HandlerFunc {
 | 
					 | 
				
			||||||
	length := len(c)
 | 
					 | 
				
			||||||
	if length > 0 {
 | 
					 | 
				
			||||||
		return c[length-1]
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return nil
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Returns a new blank Engine instance without any middleware attached.
 | 
					// Returns a new blank Engine instance without any middleware attached.
 | 
				
			||||||
// The most basic configuration
 | 
					// The most basic configuration
 | 
				
			||||||
func New() *Engine {
 | 
					func New() *Engine {
 | 
				
			||||||
 | 
				
			|||||||
@ -11,12 +11,13 @@ import (
 | 
				
			|||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type RoutesInterface interface {
 | 
					type (
 | 
				
			||||||
 | 
						RoutesInterface interface {
 | 
				
			||||||
		routesInterface
 | 
							routesInterface
 | 
				
			||||||
		Group(string, ...HandlerFunc) *RouterGroup
 | 
							Group(string, ...HandlerFunc) *RouterGroup
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type routesInterface interface {
 | 
						routesInterface interface {
 | 
				
			||||||
		Use(...HandlerFunc) routesInterface
 | 
							Use(...HandlerFunc) routesInterface
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Handle(string, string, ...HandlerFunc) routesInterface
 | 
							Handle(string, string, ...HandlerFunc) routesInterface
 | 
				
			||||||
@ -36,12 +37,13 @@ type routesInterface interface {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// Used internally to configure router, a RouterGroup is associated with a prefix
 | 
						// Used internally to configure router, a RouterGroup is associated with a prefix
 | 
				
			||||||
	// and an array of handlers (middlewares)
 | 
						// and an array of handlers (middlewares)
 | 
				
			||||||
type RouterGroup struct {
 | 
						RouterGroup struct {
 | 
				
			||||||
		Handlers HandlersChain
 | 
							Handlers HandlersChain
 | 
				
			||||||
		BasePath string
 | 
							BasePath string
 | 
				
			||||||
		engine   *Engine
 | 
							engine   *Engine
 | 
				
			||||||
		root     bool
 | 
							root     bool
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var _ RoutesInterface = &RouterGroup{}
 | 
					var _ RoutesInterface = &RouterGroup{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user