Skip to content

Commit

Permalink
Update some comments, add function name prefix to comment (gin-gonic#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mstmdev authored Mar 23, 2022
1 parent be0d86e commit 865fd56
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 24 deletions.
27 changes: 14 additions & 13 deletions gin.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ type RoutesInfo []RouteInfo

// Trusted platforms
const (
// When running on Google App Engine. Trust X-Appengine-Remote-Addr
// PlatformGoogleAppEngine when running on Google App Engine. Trust X-Appengine-Remote-Addr
// for determining the client's IP
PlatformGoogleAppEngine = "X-Appengine-Remote-Addr"
// When using Cloudflare's CDN. Trust CF-Connecting-IP for determining
// PlatformCloudflare when using Cloudflare's CDN. Trust CF-Connecting-IP for determining
// the client's IP
PlatformCloudflare = "CF-Connecting-IP"
)
Expand All @@ -80,14 +80,14 @@ const (
type Engine struct {
RouterGroup

// Enables automatic redirection if the current route can't be matched but a
// RedirectTrailingSlash enables automatic redirection if the current route can't be matched but a
// handler for the path with (without) the trailing slash exists.
// For example if /foo/ is requested but a route only exists for /foo, the
// client is redirected to /foo with http status code 301 for GET requests
// and 307 for all other request methods.
RedirectTrailingSlash bool

// If enabled, the router tries to fix the current request path, if no
// RedirectFixedPath if enabled, the router tries to fix the current request path, if no
// handle is registered for it.
// First superfluous path elements like ../ or // are removed.
// Afterwards the router does a case-insensitive lookup of the cleaned path.
Expand All @@ -98,29 +98,30 @@ type Engine struct {
// RedirectTrailingSlash is independent of this option.
RedirectFixedPath bool

// If enabled, the router checks if another method is allowed for the
// HandleMethodNotAllowed if enabled, the router checks if another method is allowed for the
// current route, if the current request can not be routed.
// If this is the case, the request is answered with 'Method Not Allowed'
// and HTTP status code 405.
// If no other Method is allowed, the request is delegated to the NotFound
// handler.
HandleMethodNotAllowed bool

// If enabled, client IP will be parsed from the request's headers that
// ForwardedByClientIP if enabled, client IP will be parsed from the request's headers that
// match those stored at `(*gin.Engine).RemoteIPHeaders`. If no IP was
// fetched, it falls back to the IP obtained from
// `(*gin.Context).Request.RemoteAddr`.
ForwardedByClientIP bool

// DEPRECATED: USE `TrustedPlatform` WITH VALUE `gin.PlatformGoogleAppEngine` INSTEAD
// AppEngine was deprecated.
// Deprecated: USE `TrustedPlatform` WITH VALUE `gin.PlatformGoogleAppEngine` INSTEAD
// #726 #755 If enabled, it will trust some headers starting with
// 'X-AppEngine...' for better integration with that PaaS.
AppEngine bool

// If enabled, the url.RawPath will be used to find parameters.
// UseRawPath if enabled, the url.RawPath will be used to find parameters.
UseRawPath bool

// If true, the path value will be unescaped.
// UnescapePathValues if true, the path value will be unescaped.
// If UseRawPath is false (by default), the UnescapePathValues effectively is true,
// as url.Path gonna be used, which is already unescaped.
UnescapePathValues bool
Expand All @@ -129,21 +130,21 @@ type Engine struct {
// See the PR #1817 and issue #1644
RemoveExtraSlash bool

// List of headers used to obtain the client IP when
// RemoteIPHeaders list of headers used to obtain the client IP when
// `(*gin.Engine).ForwardedByClientIP` is `true` and
// `(*gin.Context).Request.RemoteAddr` is matched by at least one of the
// network origins of list defined by `(*gin.Engine).SetTrustedProxies()`.
RemoteIPHeaders []string

// If set to a constant of value gin.Platform*, trusts the headers set by
// TrustedPlatform if set to a constant of value gin.Platform*, trusts the headers set by
// that platform, for example to determine the client IP
TrustedPlatform string

// Value of 'maxMemory' param that is given to http.Request's ParseMultipartForm
// MaxMultipartMemory value of 'maxMemory' param that is given to http.Request's ParseMultipartForm
// method call.
MaxMultipartMemory int64

// Enable h2c support.
// UseH2C enable h2c support.
UseH2C bool

delims render.Delims
Expand Down
6 changes: 3 additions & 3 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type LoggerConfig struct {
// Optional. Default value is gin.DefaultWriter.
Output io.Writer

// SkipPaths is a url path array which logs are not written.
// SkipPaths is an url path array which logs are not written.
// Optional.
SkipPaths []string
}
Expand Down Expand Up @@ -161,12 +161,12 @@ func ForceConsoleColor() {
consoleColorMode = forceColor
}

// ErrorLogger returns a handlerfunc for any error type.
// ErrorLogger returns a HandlerFunc for any error type.
func ErrorLogger() HandlerFunc {
return ErrorLoggerT(ErrorTypeAny)
}

// ErrorLoggerT returns a handlerfunc for a given error type.
// ErrorLoggerT returns a HandlerFunc for a given error type.
func ErrorLoggerT(typ ErrorType) HandlerFunc {
return func(c *Context) {
c.Next()
Expand Down
16 changes: 8 additions & 8 deletions response_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ type ResponseWriter interface {
http.Flusher
http.CloseNotifier

// Returns the HTTP response status code of the current request.
// Status returns the HTTP response status code of the current request.
Status() int

// Returns the number of bytes already written into the response http body.
// Size returns the number of bytes already written into the response http body.
// See Written()
Size() int

// Writes the string into the response body.
// WriteString writes the string into the response body.
WriteString(string) (int, error)

// Returns true if the response body was already written.
// Written returns true if the response body was already written.
Written() bool

// Forces to write the http header (status code + headers).
// WriteHeaderNow forces to write the http header (status code + headers).
WriteHeaderNow()

// get the http.Pusher for server push
// Pusher get the http.Pusher for server push
Pusher() http.Pusher
}

Expand Down Expand Up @@ -107,12 +107,12 @@ func (w *responseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
return w.ResponseWriter.(http.Hijacker).Hijack()
}

// CloseNotify implements the http.CloseNotify interface.
// CloseNotify implements the http.CloseNotifier interface.
func (w *responseWriter) CloseNotify() <-chan bool {
return w.ResponseWriter.(http.CloseNotifier).CloseNotify()
}

// Flush implements the http.Flush interface.
// Flush implements the http.Flusher interface.
func (w *responseWriter) Flush() {
w.WriteHeaderNow()
w.ResponseWriter.(http.Flusher).Flush()
Expand Down

0 comments on commit 865fd56

Please sign in to comment.