update func comment (#981)
This commit is contained in:
		@ -151,7 +151,7 @@ func (c *Context) AbortWithError(code int, err error) *Error {
 | 
				
			|||||||
/********* ERROR MANAGEMENT *********/
 | 
					/********* ERROR MANAGEMENT *********/
 | 
				
			||||||
/************************************/
 | 
					/************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Attaches an error to the current context. The error is pushed to a list of errors.
 | 
					// Error attaches an error to the current context. The error is pushed to a list of errors.
 | 
				
			||||||
// It's a good idea to call Error for each error that occurred during the resolution of a request.
 | 
					// It's a good idea to call Error for each error that occurred during the resolution of a request.
 | 
				
			||||||
// A middleware can be used to collect all the errors
 | 
					// A middleware can be used to collect all the errors
 | 
				
			||||||
// and push them to a database together, print a log, or append it in the HTTP response.
 | 
					// and push them to a database together, print a log, or append it in the HTTP response.
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										11
									
								
								errors.go
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								errors.go
									
									
									
									
									
								
							@ -69,7 +69,7 @@ func (msg *Error) MarshalJSON() ([]byte, error) {
 | 
				
			|||||||
	return json.Marshal(msg.JSON())
 | 
						return json.Marshal(msg.JSON())
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Implements the error interface
 | 
					// Error implements the error interface
 | 
				
			||||||
func (msg Error) Error() string {
 | 
					func (msg Error) Error() string {
 | 
				
			||||||
	return msg.Err.Error()
 | 
						return msg.Err.Error()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -78,7 +78,7 @@ func (msg *Error) IsType(flags ErrorType) bool {
 | 
				
			|||||||
	return (msg.Type & flags) > 0
 | 
						return (msg.Type & flags) > 0
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Returns a readonly copy filtered the byte.
 | 
					// ByType returns a readonly copy filtered the byte.
 | 
				
			||||||
// ie ByType(gin.ErrorTypePublic) returns a slice of errors with type=ErrorTypePublic
 | 
					// ie ByType(gin.ErrorTypePublic) returns a slice of errors with type=ErrorTypePublic
 | 
				
			||||||
func (a errorMsgs) ByType(typ ErrorType) errorMsgs {
 | 
					func (a errorMsgs) ByType(typ ErrorType) errorMsgs {
 | 
				
			||||||
	if len(a) == 0 {
 | 
						if len(a) == 0 {
 | 
				
			||||||
@ -96,17 +96,16 @@ func (a errorMsgs) ByType(typ ErrorType) errorMsgs {
 | 
				
			|||||||
	return result
 | 
						return result
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Returns the last error in the slice. It returns nil if the array is empty.
 | 
					// Last returns the last error in the slice. It returns nil if the array is empty.
 | 
				
			||||||
// Shortcut for errors[len(errors)-1]
 | 
					// Shortcut for errors[len(errors)-1]
 | 
				
			||||||
func (a errorMsgs) Last() *Error {
 | 
					func (a errorMsgs) Last() *Error {
 | 
				
			||||||
	length := len(a)
 | 
						if length := len(a); length > 0 {
 | 
				
			||||||
	if length > 0 {
 | 
					 | 
				
			||||||
		return a[length-1]
 | 
							return a[length-1]
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Returns an array will all the error messages.
 | 
					// Errors returns an array will all the error messages.
 | 
				
			||||||
// Example:
 | 
					// Example:
 | 
				
			||||||
// 		c.Error(errors.New("first"))
 | 
					// 		c.Error(errors.New("first"))
 | 
				
			||||||
// 		c.Error(errors.New("second"))
 | 
					// 		c.Error(errors.New("second"))
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										4
									
								
								fs.go
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								fs.go
									
									
									
									
									
								
							@ -29,7 +29,7 @@ func Dir(root string, listDirectory bool) http.FileSystem {
 | 
				
			|||||||
	return &onlyfilesFS{fs}
 | 
						return &onlyfilesFS{fs}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Conforms to http.Filesystem
 | 
					// Open conforms to http.Filesystem
 | 
				
			||||||
func (fs onlyfilesFS) Open(name string) (http.File, error) {
 | 
					func (fs onlyfilesFS) Open(name string) (http.File, error) {
 | 
				
			||||||
	f, err := fs.fs.Open(name)
 | 
						f, err := fs.fs.Open(name)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
@ -38,7 +38,7 @@ func (fs onlyfilesFS) Open(name string) (http.File, error) {
 | 
				
			|||||||
	return neuteredReaddirFile{f}, nil
 | 
						return neuteredReaddirFile{f}, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Overrides the http.File default implementation
 | 
					// Readdir overrides the http.File default implementation
 | 
				
			||||||
func (f neuteredReaddirFile) Readdir(count int) ([]os.FileInfo, error) {
 | 
					func (f neuteredReaddirFile) Readdir(count int) ([]os.FileInfo, error) {
 | 
				
			||||||
	// this disables directory listing
 | 
						// this disables directory listing
 | 
				
			||||||
	return nil, nil
 | 
						return nil, nil
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										4
									
								
								gin.go
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								gin.go
									
									
									
									
									
								
							@ -285,7 +285,7 @@ func (engine *Engine) RunUnix(file string) (err error) {
 | 
				
			|||||||
	return
 | 
						return
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Conforms to the http.Handler interface.
 | 
					// ServeHTTP conforms to the http.Handler interface.
 | 
				
			||||||
func (engine *Engine) ServeHTTP(w http.ResponseWriter, req *http.Request) {
 | 
					func (engine *Engine) ServeHTTP(w http.ResponseWriter, req *http.Request) {
 | 
				
			||||||
	c := engine.pool.Get().(*Context)
 | 
						c := engine.pool.Get().(*Context)
 | 
				
			||||||
	c.writermem.reset(w)
 | 
						c.writermem.reset(w)
 | 
				
			||||||
@ -297,7 +297,7 @@ func (engine *Engine) ServeHTTP(w http.ResponseWriter, req *http.Request) {
 | 
				
			|||||||
	engine.pool.Put(c)
 | 
						engine.pool.Put(c)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Re-enter a context that has been rewritten.
 | 
					// HandleContext re-enter a context that has been rewritten.
 | 
				
			||||||
// This can be done by setting c.Request.Path to your new target.
 | 
					// This can be done by setting c.Request.Path to your new target.
 | 
				
			||||||
// Disclaimer: You can loop yourself to death with this, use wisely.
 | 
					// Disclaimer: You can loop yourself to death with this, use wisely.
 | 
				
			||||||
func (engine *Engine) HandleContext(c *Context) {
 | 
					func (engine *Engine) HandleContext(c *Context) {
 | 
				
			||||||
 | 
				
			|||||||
@ -95,7 +95,7 @@ func (w *responseWriter) Written() bool {
 | 
				
			|||||||
	return w.size != noWritten
 | 
						return w.size != noWritten
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Implements the http.Hijacker interface
 | 
					// Hijack implements the http.Hijacker interface
 | 
				
			||||||
func (w *responseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
 | 
					func (w *responseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
 | 
				
			||||||
	if w.size < 0 {
 | 
						if w.size < 0 {
 | 
				
			||||||
		w.size = 0
 | 
							w.size = 0
 | 
				
			||||||
@ -103,12 +103,12 @@ func (w *responseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
 | 
				
			|||||||
	return w.ResponseWriter.(http.Hijacker).Hijack()
 | 
						return w.ResponseWriter.(http.Hijacker).Hijack()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Implements the http.CloseNotify interface
 | 
					// CloseNotify implements the http.CloseNotify interface
 | 
				
			||||||
func (w *responseWriter) CloseNotify() <-chan bool {
 | 
					func (w *responseWriter) CloseNotify() <-chan bool {
 | 
				
			||||||
	return w.ResponseWriter.(http.CloseNotifier).CloseNotify()
 | 
						return w.ResponseWriter.(http.CloseNotifier).CloseNotify()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Implements the http.Flush interface
 | 
					// Flush implements the http.Flush interface
 | 
				
			||||||
func (w *responseWriter) Flush() {
 | 
					func (w *responseWriter) Flush() {
 | 
				
			||||||
	w.ResponseWriter.(http.Flusher).Flush()
 | 
						w.ResponseWriter.(http.Flusher).Flush()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										4
									
								
								tree.go
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								tree.go
									
									
									
									
									
								
							@ -357,7 +357,7 @@ func (n *node) insertChild(numParams uint8, path string, fullPath string, handle
 | 
				
			|||||||
	n.handlers = handlers
 | 
						n.handlers = handlers
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Returns the handle registered with the given path (key). The values of
 | 
					// getValue returns the handle registered with the given path (key). The values of
 | 
				
			||||||
// wildcards are saved to a map.
 | 
					// wildcards are saved to a map.
 | 
				
			||||||
// If no handle can be found, a TSR (trailing slash redirect) recommendation is
 | 
					// If no handle can be found, a TSR (trailing slash redirect) recommendation is
 | 
				
			||||||
// made if a handle exists with an extra (without the) trailing slash for the
 | 
					// made if a handle exists with an extra (without the) trailing slash for the
 | 
				
			||||||
@ -499,7 +499,7 @@ walk: // Outer loop for walking the tree
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Makes a case-insensitive lookup of the given path and tries to find a handler.
 | 
					// findCaseInsensitivePath makes a case-insensitive lookup of the given path and tries to find a handler.
 | 
				
			||||||
// It can optionally also fix trailing slashes.
 | 
					// It can optionally also fix trailing slashes.
 | 
				
			||||||
// It returns the case-corrected path and a bool indicating whether the lookup
 | 
					// It returns the case-corrected path and a bool indicating whether the lookup
 | 
				
			||||||
// was successful.
 | 
					// was successful.
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user