diff --git a/AGENTS.md b/AGENTS.md index 54eb6c60c03..24a89a1870b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -2,7 +2,7 @@ ## Agent Instructions -> **Note for the AI agent:** Before running the startup script, verify that all dependencies and CLI tools are already available. If a `vendor/` directory exists **or** `go list -m -mod=readonly all` succeeds (indicating modules are cached), you may skip the entire startup script—including all `go mod` commands and `go install` steps. Otherwise run the script as listed below. +> **Note for the AI agent:** Before running the startup script, verify that all dependencies and CLI tools are already available. If a `vendor/` directory exists **or** `go list -m -mod=readonly all` succeeds (indicating modules are cached), you may skip the entire startup script—including all `go mod` commands and `go install` steps. Otherwise, run the script as listed below. --- diff --git a/app.go b/app.go index ba731e1c851..ba00a6c2b83 100644 --- a/app.go +++ b/app.go @@ -1,5 +1,5 @@ // ⚡️ Fiber is an Express inspired web framework written in Go with ☕️ -// 🤖 Github Repository: https://github.com/gofiber/fiber +// 🤖 GitHub Repository: https://github.com/gofiber/fiber // 📌 API Documentation: https://docs.gofiber.io // Package fiber is an Express inspired web framework built on top of Fasthttp, @@ -637,7 +637,7 @@ func NewWithCustomCtx(newCtxFunc func(app *App) CustomCtx, config ...Config) *Ap } // GetString returns s unchanged when Immutable is off or s is read-only (rodata). -// Otherwise it returns a detached copy (strings.Clone). +// Otherwise, it returns a detached copy (strings.Clone). func (app *App) GetString(s string) string { if !app.config.Immutable || len(s) == 0 { return s @@ -649,7 +649,7 @@ func (app *App) GetString(s string) string { } // GetBytes returns b unchanged when Immutable is off or b is read-only (rodata). -// Otherwise it returns a detached copy. +// Otherwise, it returns a detached copy. func (app *App) GetBytes(b []byte) []byte { if !app.config.Immutable || len(b) == 0 { return b @@ -1015,7 +1015,7 @@ func (app *App) HandlersCount() uint32 { // // Make sure the program doesn't exit and waits instead for Shutdown to return. // -// Important: app.Listen() must be called in a separate goroutine, otherwise shutdown hooks will not work +// Important: app.Listen() must be called in a separate goroutine; otherwise, shutdown hooks will not work // as Listen() is a blocking operation. Example: // // go app.Listen(":3000") @@ -1263,7 +1263,7 @@ func (app *App) init() *App { // ErrorHandler is the application's method in charge of finding the // appropriate handler for the given request. It searches any mounted // sub fibers by their prefixes and if it finds a match, it uses that -// error handler. Otherwise it uses the configured error handler for +// error handler. Otherwise, it uses the configured error handler for // the app, which if not set is the DefaultErrorHandler. func (app *App) ErrorHandler(ctx Ctx, err error) error { var ( diff --git a/app_test.go b/app_test.go index 683ed73a7b1..f576da39069 100644 --- a/app_test.go +++ b/app_test.go @@ -1,5 +1,5 @@ // ⚡️ Fiber is an Express inspired web framework written in Go with ☕️ -// 🤖 Github Repository: https://github.com/gofiber/fiber +// 🤖 GitHub Repository: https://github.com/gofiber/fiber // 📌 API Documentation: https://docs.gofiber.io package fiber @@ -530,7 +530,7 @@ func Test_App_ErrorHandler_Custom(t *testing.T) { t.Parallel() app := New(Config{ ErrorHandler: func(c Ctx, _ error) error { - return c.Status(200).SendString("hi, i'm an custom error") + return c.Status(200).SendString("hi, i'm a custom error") }, }) @@ -544,7 +544,7 @@ func Test_App_ErrorHandler_Custom(t *testing.T) { body, err := io.ReadAll(resp.Body) require.NoError(t, err) - require.Equal(t, "hi, i'm an custom error", string(body)) + require.Equal(t, "hi, i'm a custom error", string(body)) } func Test_App_ErrorHandler_HandlerStack(t *testing.T) { diff --git a/bind.go b/bind.go index 6376fa7481b..34dab5c992e 100644 --- a/bind.go +++ b/bind.go @@ -151,7 +151,7 @@ func (b *Bind) RespHeader(out any) error { } // Cookie binds the request cookie strings into the struct, map[string]string and map[string][]string. -// NOTE: If your cookie is like key=val1,val2; they'll be binded as an slice if your map is map[string][]string. Else, it'll use last element of cookie. +// NOTE: If your cookie is like key=val1,val2; they'll be bound as a slice if your map is map[string][]string. Else, it'll use last element of cookie. func (b *Bind) Cookie(out any) error { bind := binder.GetFromThePool[*binder.CookieBinding](&binder.CookieBinderPool) bind.EnableSplitting = b.ctx.App().config.EnableSplittingOnParsers @@ -299,7 +299,7 @@ func (b *Bind) MsgPack(out any) error { // It supports decoding the following content types based on the Content-Type header: // application/json, application/xml, application/x-www-form-urlencoded, multipart/form-data // If none of the content types above are matched, it'll take a look custom binders by checking the MIMETypes() method of custom binder. -// If there're no custom binder for mime type of body, it will return a ErrUnprocessableEntity error. +// If there is no custom binder for mime type of body, it will return a ErrUnprocessableEntity error. func (b *Bind) Body(out any) error { // Get content-type ctype := utils.ToLower(utils.UnsafeString(b.ctx.RequestCtx().Request.Header.ContentType())) diff --git a/bind_test.go b/bind_test.go index ffa99e89c8b..e42f74ac478 100644 --- a/bind_test.go +++ b/bind_test.go @@ -72,7 +72,7 @@ func Test_Bind_Query(t *testing.T) { require.NoError(t, c.Bind().Query(q)) require.Len(t, q.Hobby, 2) - c.Request().URI().SetQueryString("id=1&name=tom&hobby=scoccer&hobby=basketball,football") + c.Request().URI().SetQueryString("id=1&name=tom&hobby=soccer&hobby=basketball,football") q = new(Query) require.NoError(t, c.Bind().Query(q)) require.Len(t, q.Hobby, 3) @@ -148,12 +148,12 @@ func Test_Bind_Query_Map(t *testing.T) { require.NoError(t, c.Bind().Query(&q)) require.Len(t, q["hobby"], 2) - c.Request().URI().SetQueryString("id=1&name=tom&hobby=scoccer&hobby=basketball,football") + c.Request().URI().SetQueryString("id=1&name=tom&hobby=soccer&hobby=basketball,football") q = make(map[string][]string) require.NoError(t, c.Bind().Query(&q)) require.Len(t, q["hobby"], 3) - c.Request().URI().SetQueryString("id=1&name=tom&hobby=scoccer") + c.Request().URI().SetQueryString("id=1&name=tom&hobby=soccer") qq := make(map[string]string) require.NoError(t, c.Bind().Query(&qq)) require.Equal(t, "1", qq["id"]) diff --git a/client/client_test.go b/client/client_test.go index e14f1e4e47a..216d1818a54 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -1338,7 +1338,7 @@ func Test_Client_Header(t *testing.T) { require.Equal(t, "foo", res[0]) }) - t.Run("set header case insensitive", func(t *testing.T) { + t.Run("set header case-insensitive", func(t *testing.T) { t.Parallel() req := New() req.SetHeader("foo", "bar"). diff --git a/client/hooks_test.go b/client/hooks_test.go index 6766cacc908..32d6eb749bf 100644 --- a/client/hooks_test.go +++ b/client/hooks_test.go @@ -326,7 +326,7 @@ func Test_Parser_Request_Header(t *testing.T) { req := AcquireRequest(). SetFormDataWithMap(map[string]string{ "foo": "bar", - "ball": "cricle and square", + "ball": "circle and square", }) err := parserRequestHeader(client, req) @@ -531,12 +531,12 @@ func Test_Parser_Request_Body(t *testing.T) { client := New() req := AcquireRequest(). SetFormDataWithMap(map[string]string{ - "ball": "cricle and square", + "ball": "circle and square", }) err := parserRequestBody(client, req) require.NoError(t, err) - require.Equal(t, "ball=cricle+and+square", string(req.RawRequest.Body())) + require.Equal(t, "ball=circle+and+square", string(req.RawRequest.Body())) }) t.Run("form data body error", func(t *testing.T) { diff --git a/color.go b/color.go index cbccd2ebee7..a1d362a4e40 100644 --- a/color.go +++ b/color.go @@ -1,5 +1,5 @@ // ⚡️ Fiber is an Express inspired web framework written in Go with ☕️ -// 🤖 Github Repository: https://github.com/gofiber/fiber +// 🤖 GitHub Repository: https://github.com/gofiber/fiber // 📌 API Documentation: https://docs.gofiber.io package fiber diff --git a/ctx.go b/ctx.go index d876d9d78ee..92be086524f 100644 --- a/ctx.go +++ b/ctx.go @@ -1,5 +1,5 @@ // ⚡️ Fiber is an Express inspired web framework written in Go with ☕️ -// 🤖 Github Repository: https://github.com/gofiber/fiber +// 🤖 GitHub Repository: https://github.com/gofiber/fiber // 📌 API Documentation: https://docs.gofiber.io package fiber diff --git a/ctx_interface.go b/ctx_interface.go index f6f76361c87..071e328c2ae 100644 --- a/ctx_interface.go +++ b/ctx_interface.go @@ -1,5 +1,5 @@ // ⚡️ Fiber is an Express inspired web framework written in Go with ☕️ -// 🤖 Github Repository: https://github.com/gofiber/fiber +// 🤖 GitHub Repository: https://github.com/gofiber/fiber // 📌 API Documentation: https://docs.gofiber.io package fiber diff --git a/ctx_interface_gen.go b/ctx_interface_gen.go index 3eb5c8bfe37..3d7e35859c7 100644 --- a/ctx_interface_gen.go +++ b/ctx_interface_gen.go @@ -214,19 +214,19 @@ type Ctx interface { // while `Hostname` refers specifically to the name assigned to a device on a network, excluding any port information. // Example: URL: https://example.com:8080 -> Host: example.com:8080 // Make copies or use the Immutable setting instead. - // Please use Config.TrustProxy to prevent header spoofing, in case when your app is behind the proxy. + // Please use Config.TrustProxy to prevent header spoofing if your app is behind a proxy. Host() string // Hostname contains the hostname derived from the X-Forwarded-Host or Host HTTP header using the c.Host() method. // Returned value is only valid within the handler. Do not store any references. // Example: URL: https://example.com:8080 -> Hostname: example.com // Make copies or use the Immutable setting instead. - // Please use Config.TrustProxy to prevent header spoofing, in case when your app is behind the proxy. + // Please use Config.TrustProxy to prevent header spoofing if your app is behind a proxy. Hostname() string // Port returns the remote port of the request. Port() string // IP returns the remote IP address of the request. // If ProxyHeader and IP Validation is configured, it will parse that header and return the first valid IP address. - // Please use Config.TrustProxy to prevent header spoofing, in case when your app is behind the proxy. + // Please use Config.TrustProxy to prevent header spoofing if your app is behind a proxy. IP() string // extractIPsFromHeader will return a slice of IPs it found given a header name in the order they appear. // When IP validation is enabled, any invalid IPs will be omitted. @@ -254,7 +254,7 @@ type Ctx interface { // Otherwise, it updates the context's method and returns the overridden method as a string. Method(override ...string) string // MultipartForm parse form entries from binary. - // This returns a map[string][]string, so given a key the value will be a string slice. + // This returns a map[string][]string, so given a key, the value will be a string slice. MultipartForm() (*multipart.Form, error) // Params is used to get the route parameters. // Defaults to empty string "" if the param doesn't exist. @@ -263,7 +263,7 @@ type Ctx interface { // Make copies or use the Immutable setting to use the value outside the Handler. Params(key string, defaultValue ...string) string // Scheme contains the request protocol string: http or https for TLS requests. - // Please use Config.TrustProxy to prevent header spoofing, in case when your app is behind the proxy. + // Please use Config.TrustProxy to prevent header spoofing if your app is behind a proxy. Scheme() string // Protocol returns the HTTP protocol of request: HTTP/1.1 and HTTP/2. Protocol() string @@ -409,7 +409,7 @@ type Ctx interface { // Type sets the Content-Type HTTP header to the MIME type specified by the file extension. Type(extension string, charset ...string) Ctx // Vary adds the given header field to the Vary response header. - // This will append the header, if not already listed, otherwise leaves it listed in the current location. + // This will append the header, if not already listed; otherwise, leaves it listed in the current location. Vary(fields ...string) // Write appends p into response body. Write(p []byte) (int, error) diff --git a/ctx_test.go b/ctx_test.go index 30afa070d84..5de8256415c 100644 --- a/ctx_test.go +++ b/ctx_test.go @@ -1,5 +1,5 @@ // ⚡️ Fiber is an Express inspired web framework written in Go with ☕️ -// 🤖 Github Repository: https://github.com/gofiber/fiber +// 🤖 GitHub Repository: https://github.com/gofiber/fiber // 📌 API Documentation: https://docs.gofiber.io package fiber @@ -3307,7 +3307,7 @@ func Test_Ctx_Path(t *testing.T) { app.Get("/test/:user", func(c Ctx) error { require.Equal(t, "/Test/John", c.Path()) require.Equal(t, "/Test/John", string(c.Request().URI().Path())) - // not strict && case insensitive + // not strict && case-insensitive require.Equal(t, "/ABC/", c.Path("/ABC/")) require.Equal(t, "/ABC/", string(c.Request().URI().Path())) require.Equal(t, "/test/john/", c.Path("/test/john/")) @@ -5583,7 +5583,7 @@ func Benchmark_Ctx_Get_Location_From_Route(b *testing.B) { func Test_Ctx_Get_Location_From_Route_name(t *testing.T) { t.Parallel() - t.Run("case insensitive", func(t *testing.T) { + t.Run("case-insensitive", func(t *testing.T) { t.Parallel() app := New() c := app.AcquireCtx(&fasthttp.RequestCtx{}) @@ -5600,7 +5600,7 @@ func Test_Ctx_Get_Location_From_Route_name(t *testing.T) { require.Equal(t, "/user/fiber", location) }) - t.Run("case sensitive", func(t *testing.T) { + t.Run("case-sensitive", func(t *testing.T) { t.Parallel() app := New(Config{CaseSensitive: true}) c := app.AcquireCtx(&fasthttp.RequestCtx{}) diff --git a/docs/api/app.md b/docs/api/app.md index 17863181b0d..0bfcad08f20 100644 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -11,7 +11,7 @@ import Reference from '@site/src/components/reference'; ### GetString -Returns `s` unchanged when [`Immutable`](./fiber.md#immutable) is disabled or `s` resides in read-only memory. Otherwise it returns a detached copy using `strings.Clone`. +Returns `s` unchanged when [`Immutable`](./fiber.md#immutable) is disabled or `s` resides in read-only memory. Otherwise, it returns a detached copy using `strings.Clone`. ```go title="Signature" func (app *App) GetString(s string) string @@ -19,7 +19,7 @@ func (app *App) GetString(s string) string ### GetBytes -Returns `b` unchanged when [`Immutable`](./fiber.md#immutable) is disabled or `b` resides in read-only memory. Otherwise it returns a detached copy. +Returns `b` unchanged when [`Immutable`](./fiber.md#immutable) is disabled or `b` resides in read-only memory. Otherwise, it returns a detached copy. ```go title="Signature" func (app *App) GetBytes(b []byte) []byte diff --git a/docs/api/ctx.md b/docs/api/ctx.md index 8a9b5c6456c..cc37f8d1ed2 100644 --- a/docs/api/ctx.md +++ b/docs/api/ctx.md @@ -796,7 +796,7 @@ Make copies or use the [**`Immutable`**](./fiber.md#immutable) setting instead. ### Fresh -When the response is still **fresh** in the client's cache **true** is returned, otherwise **false** is returned to indicate that the client cache is now stale and the full response should be sent. +When the response is still **fresh** in the client's cache **true** is returned; otherwise, **false** is returned to indicate that the client cache is now stale and the full response should be sent. When a client sends the Cache-Control: no-cache request header to indicate an end-to-end reload request, `Fresh` will return false to make handling these requests transparent. diff --git a/docs/api/services.md b/docs/api/services.md index 52525920115..f5fddab625b 100644 --- a/docs/api/services.md +++ b/docs/api/services.md @@ -10,7 +10,7 @@ After adding a service to the app configuration, Fiber starts it on launch and s ## Service Interface -The `Service` interface defines the methods a service must implement. +The `Service` interface defines methods a service must implement. ### Definition diff --git a/docs/api/state.md b/docs/api/state.md index 5d6bd66d0c7..ca0a3e6a446 100644 --- a/docs/api/state.md +++ b/docs/api/state.md @@ -464,7 +464,7 @@ func GetStateWithDefault[T any](s *State, key string, defaultVal T) T **Usage Example:** ```go -// Retrieve a value with a default fallback. +// Retrieve a value with a fallback. requestCount := GetStateWithDefault[int](app.State(), "requestCount", 0) fmt.Printf("Request Count: %d\n", requestCount) ``` diff --git a/docs/extra/internal.md b/docs/extra/internal.md index 2bd310a4d00..8b2082c5286 100644 --- a/docs/extra/internal.md +++ b/docs/extra/internal.md @@ -265,7 +265,7 @@ Reusing Context objects significantly reduces garbage collection overhead, ensur ## Preforking Mechanism -To take full advantage of multi‑core systems, Fiber offers a prefork mode. In this mode, the master process spawns several child processes that listen on the same port using OS features such as SO_REUSEPORT (or a fallback to SO_REUSEADDR). +To take full advantage of multi‑core systems, Fiber offers a prefork mode. In this mode, the master process spawns several child processes that listen on the same port using OS features such as SO_REUSEPORT (or fall back to SO_REUSEADDR). ```mermaid flowchart LR diff --git a/docs/guide/extractors.md b/docs/guide/extractors.md index cbc1b42fb8c..939ea4d57e5 100644 --- a/docs/guide/extractors.md +++ b/docs/guide/extractors.md @@ -201,7 +201,7 @@ Different extraction sources have different security properties and use cases: When using multiple sources, order them by your security preferences: ```go -// Example: Prefer headers, fallback to cookies, then query +// Example: Prefer headers, fall back to cookies, then query extractors.Chain( extractors.FromAuthHeader("Bearer"), // Standard auth extractors.FromCookie("auth_token"), // Secure storage diff --git a/docs/middleware/csrf.md b/docs/middleware/csrf.md index 931b030b02c..c5d7cb39881 100644 --- a/docs/middleware/csrf.md +++ b/docs/middleware/csrf.md @@ -300,7 +300,7 @@ You can create advanced extractors for use cases like JWT embedding or JSON body For applications that need to support both AJAX and form submissions: ```go -// Try header first (AJAX), fallback to form (traditional forms) +// Try header first (AJAX), fall back to form (traditional forms) app.Use(csrf.New(csrf.Config{ Extractor: extractors.Chain( extractors.FromHeader("X-Csrf-Token"), diff --git a/docs/whats_new.md b/docs/whats_new.md index 7692bc4a43c..a17950a04fb 100644 --- a/docs/whats_new.md +++ b/docs/whats_new.md @@ -1173,7 +1173,7 @@ We've made some changes to the CORS middleware to improve its functionality and #### New Struct Fields -- `Config.AllowPrivateNetwork`: This new field is a boolean that allows you to control whether private networks are allowed. This is related to the [Private Network Access (PNA)](https://wicg.github.io/private-network-access/) specification from the Web Incubator Community Group (WICG). When set to `true`, the CORS middleware will allow CORS preflight requests from private networks and respond with the `Access-Control-Allow-Private-Network: true` header. This could be useful in development environments or specific use cases, but should be done with caution due to potential security risks. +- `Config.AllowPrivateNetwork`: This new field is a boolean that allows you to control whether private networks are allowed. This is related to the [Private Network Access (PNA)](https://wicg.github.io/private-network-access/) specification from the [Web Incubator Community Group (WICG)](https://wicg.io/). When set to `true`, the CORS middleware will allow CORS preflight requests from private networks and respond with the `Access-Control-Allow-Private-Network: true` header. This could be useful in development environments or specific use cases, but should be done with caution due to potential security risks. #### Updated Struct Fields diff --git a/group.go b/group.go index 4e74bad8289..22430658d92 100644 --- a/group.go +++ b/group.go @@ -1,5 +1,5 @@ // ⚡️ Fiber is an Express inspired web framework written in Go with ☕️ -// 🤖 Github Repository: https://github.com/gofiber/fiber +// 🤖 GitHub Repository: https://github.com/gofiber/fiber // 📌 API Documentation: https://docs.gofiber.io package fiber diff --git a/helpers.go b/helpers.go index 83c2057c1b0..f61fbdbd995 100644 --- a/helpers.go +++ b/helpers.go @@ -1,5 +1,5 @@ // ⚡️ Fiber is an Express inspired web framework written in Go with ☕️ -// 🤖 Github Repository: https://github.com/gofiber/fiber +// 🤖 GitHub Repository: https://github.com/gofiber/fiber // 📌 API Documentation: https://docs.gofiber.io package fiber @@ -308,7 +308,7 @@ func acceptsOfferType(spec, offerType string, specParams headerParams) bool { } // paramsMatch returns whether offerParams contains all parameters present in specParams. -// Matching is case insensitive, and surrounding quotes are stripped. +// Matching is case-insensitive, and surrounding quotes are stripped. // To align with the behavior of res.format from Express, the order of parameters is // ignored, and if a parameter is specified twice in the incoming Accept, the last // provided value is given precedence. diff --git a/helpers_test.go b/helpers_test.go index bd95653c994..ba347275c61 100644 --- a/helpers_test.go +++ b/helpers_test.go @@ -1,5 +1,5 @@ // ⚡️ Fiber is an Express inspired web framework written in Go with ☕️ -// 📝 Github Repository: https://github.com/gofiber/fiber +// 📝 GitHub Repository: https://github.com/gofiber/fiber // 📌 API Documentation: https://docs.gofiber.io package fiber @@ -222,7 +222,7 @@ func Test_Utils_ParamsMatch(t *testing.T) { match: true, }, { - description: "case insensitive", + description: "case-insensitive", accept: headerParams{"ParaM": []byte("FoO")}, offer: ";pAram=foO", match: true, diff --git a/hooks_test.go b/hooks_test.go index 32e5b874a68..0edb3b3e14d 100644 --- a/hooks_test.go +++ b/hooks_test.go @@ -178,7 +178,7 @@ func Test_Hook_OnGroupName_Error(t *testing.T) { }) } -func Test_Hook_OnPrehutdown(t *testing.T) { +func Test_Hook_OnPreShutdown(t *testing.T) { t.Parallel() app := New() @@ -186,14 +186,14 @@ func Test_Hook_OnPrehutdown(t *testing.T) { defer bytebufferpool.Put(buf) app.Hooks().OnPreShutdown(func() error { - _, err := buf.WriteString("pre-shutdowning") + _, err := buf.WriteString("pre-shutdown") require.NoError(t, err) return nil }) require.NoError(t, app.Shutdown()) - require.Equal(t, "pre-shutdowning", buf.String()) + require.Equal(t, "pre-shutdown", buf.String()) } func Test_Hook_OnPostShutdown(t *testing.T) { diff --git a/listen.go b/listen.go index 0d8e9fcb864..9ea364b9a78 100644 --- a/listen.go +++ b/listen.go @@ -1,5 +1,5 @@ // ⚡️ Fiber is an Express inspired web framework written in Go with ☕️ -// 🤖 Github Repository: https://github.com/gofiber/fiber +// 🤖 GitHub Repository: https://github.com/gofiber/fiber // 📌 API Documentation: https://docs.gofiber.io package fiber diff --git a/middleware/cache/cache_test.go b/middleware/cache/cache_test.go index 3a1b2a26edb..d5430422c38 100644 --- a/middleware/cache/cache_test.go +++ b/middleware/cache/cache_test.go @@ -533,7 +533,7 @@ func Test_Cache_WithSeveralRequests(t *testing.T) { a, err := strconv.Atoi(string(idFromServ)) require.NoError(t, err) - // SomeTimes,The id is not equal with a + // Sometimes, the id is not equal to a require.Equal(t, id, a) }(i) } @@ -1073,7 +1073,7 @@ func Test_CacheStorage_CustomHeaders(t *testing.T) { } // Because time points are updated once every X milliseconds, entries in tests can often have -// equal expiration times and thus be in an random order. This closure hands out increasing +// equal expiration times and thus be in a random order. This closure hands out increasing // time intervals to maintain strong ascending order of expiration func stableAscendingExpiration() func(c1 fiber.Ctx, c2 *Config) time.Duration { i := 0 diff --git a/middleware/cache/config.go b/middleware/cache/config.go index e8e7156ee8c..4fb01c0aafe 100644 --- a/middleware/cache/config.go +++ b/middleware/cache/config.go @@ -50,7 +50,7 @@ type Config struct { // Default: []string{fiber.MethodGet, fiber.MethodHead} Methods []string - // Expiration is the time that an cached response will live + // Expiration is the time that a cached response will live // // Optional. Default: 5 * time.Minute Expiration time.Duration diff --git a/middleware/cors/cors.go b/middleware/cors/cors.go index 708fd069f99..e84edf211b6 100644 --- a/middleware/cors/cors.go +++ b/middleware/cors/cors.go @@ -44,7 +44,7 @@ func New(config ...Config) fiber.Handler { // allowOrigins is a slice of strings that contains the allowed origins // defined in the 'AllowOrigins' configuration. allowOrigins := []string{} - allowSOrigins := []subdomain{} + allowSubOrigins := []subdomain{} // Validate and normalize static AllowOrigins allowAllOrigins := len(cfg.AllowOrigins) == 0 && cfg.AllowOriginsFunc == nil @@ -63,7 +63,7 @@ func New(config ...Config) fiber.Handler { } schemeSep := strings.Index(normalizedOrigin, "://") + len("://") sd := subdomain{prefix: normalizedOrigin[:schemeSep], suffix: normalizedOrigin[schemeSep:]} - allowSOrigins = append(allowSOrigins, sd) + allowSubOrigins = append(allowSubOrigins, sd) } else { isValid, normalizedOrigin := normalizeOrigin(trimmedOrigin) if !isValid { @@ -132,7 +132,7 @@ func New(config ...Config) fiber.Handler { // Check if the origin is in the list of allowed subdomains if allowOrigin == "" { - for _, sOrigin := range allowSOrigins { + for _, sOrigin := range allowSubOrigins { if sOrigin.match(originHeader) { allowOrigin = originHeaderRaw break diff --git a/middleware/csrf/csrf_test.go b/middleware/csrf/csrf_test.go index e7e0ad60f28..6ad057405bc 100644 --- a/middleware/csrf/csrf_test.go +++ b/middleware/csrf/csrf_test.go @@ -1763,7 +1763,7 @@ func Test_CSRF_Chain_Extractor(t *testing.T) { t.Parallel() app := fiber.New() - // Chain extractor: try header first, fallback to form + // Chain extractor: try header first, fall back to form chainExtractor := extractors.Chain( extractors.FromHeader("X-Csrf-Token"), extractors.FromForm("_csrf"), @@ -2149,7 +2149,7 @@ func Test_CSRF_Extractors_ErrorTypes(t *testing.T) { app := fiber.New() requestCtx := &fasthttp.RequestCtx{} - tc.setupCtx(requestCtx) // Setup the context properly + tc.setupCtx(requestCtx) // Set up the context properly ctx := app.AcquireCtx(requestCtx) defer app.ReleaseCtx(ctx) diff --git a/middleware/earlydata/config.go b/middleware/earlydata/config.go index ced705dd570..397c364c2b6 100644 --- a/middleware/earlydata/config.go +++ b/middleware/earlydata/config.go @@ -26,7 +26,7 @@ type Config struct { // Optional. Default: a function which rejects the request on unsafe and allows the request on safe HTTP request methods. AllowEarlyData func(c fiber.Ctx) bool - // Error is returned in case an early-data request is rejected. + // Error is returned if an early-data request is rejected. // // Optional. Default: fiber.ErrTooEarly. Error error diff --git a/middleware/idempotency/locker_test.go b/middleware/idempotency/locker_test.go index 8dc75963da4..eea0353b7d0 100644 --- a/middleware/idempotency/locker_test.go +++ b/middleware/idempotency/locker_test.go @@ -114,7 +114,7 @@ func Benchmark_MemoryLock_Parallel(b *testing.B) { b.ResetTimer() b.RunParallel(func(p *testing.PB) { for p.Next() { - // Division by 3 ensures that index will be repreated exactly 3 times + // Division by 3 ensures that index will be repeated exactly 3 times i := int(keyI.Add(1)) / 3 % len(keys) key := keys[i] if err := lock.Lock(key); err != nil { diff --git a/middleware/keyauth/keyauth_test.go b/middleware/keyauth/keyauth_test.go index 31090d403c0..fc26c4d5e40 100644 --- a/middleware/keyauth/keyauth_test.go +++ b/middleware/keyauth/keyauth_test.go @@ -196,7 +196,7 @@ func TestMultipleKeyLookup(t *testing.T) { scheme = "Bearer" ) - // setup the fiber endpoint + // set up the fiber endpoint app := fiber.New() customExtractor := extractors.Chain( @@ -256,10 +256,10 @@ func TestMultipleKeyLookup(t *testing.T) { } func Test_MultipleKeyAuth(t *testing.T) { - // setup the fiber endpoint + // set up the fiber endpoint app := fiber.New() - // setup keyauth for /auth1 + // set up keyauth for /auth1 app.Use(New(Config{ Next: func(c fiber.Ctx) bool { return c.Path() != "/auth1" diff --git a/middleware/limiter/limiter_sliding.go b/middleware/limiter/limiter_sliding.go index 5b6dd900862..77833bae012 100644 --- a/middleware/limiter/limiter_sliding.go +++ b/middleware/limiter/limiter_sliding.go @@ -65,7 +65,7 @@ func (SlidingWindow) New(cfg Config) fiber.Handler { e.currHits = 0 // Check how much into the current window it currently is and sets the - // expiry based on that, otherwise this would only reset on + // expiry based on that; otherwise, this would only reset on // the next request and not show the correct expiry. elapsed := ts - e.exp if elapsed >= expiration { @@ -100,7 +100,7 @@ func (SlidingWindow) New(cfg Config) fiber.Handler { // duration + expiration = end of next window. // Because we don't want to garbage collect in the middle of a window // we add the expiration to the duration. - // Otherwise after the end of "sample window", attackers could launch + // Otherwise, after the end of "sample window", attackers could launch // a new request with the full window length. if setErr := manager.set(c, key, e, time.Duration(resetInSec+expiration)*time.Second); setErr != nil { //nolint:gosec // Not a concern mux.Unlock() diff --git a/middleware/logger/config.go b/middleware/logger/config.go index 4c23b435cf9..6c550f949b7 100644 --- a/middleware/logger/config.go +++ b/middleware/logger/config.go @@ -36,7 +36,7 @@ type Config struct { // Optional. Default: map[string]LogFunc CustomTags map[string]LogFunc - // You can define specific things before the returning the handler: colors, template, etc. + // You can define specific things before returning the handler: colors, template, etc. // // Optional. Default: beforeHandlerFunc BeforeHandlerFunc func(Config) diff --git a/middleware/logger/logger.go b/middleware/logger/logger.go index 7d4befc9213..1ece7f4ca8c 100644 --- a/middleware/logger/logger.go +++ b/middleware/logger/logger.go @@ -75,7 +75,7 @@ func New(config ...Config) fiber.Handler { // Set error handler once once.Do(func() { - // get longested possible path + // get longest possible path stack := c.App().Stack() for m := range stack { for r := range stack[m] { diff --git a/middleware/proxy/proxy.go b/middleware/proxy/proxy.go index a0056cc8802..b74cbff96ad 100644 --- a/middleware/proxy/proxy.go +++ b/middleware/proxy/proxy.go @@ -123,7 +123,7 @@ func WithClient(cli *fasthttp.Client) { } // Forward performs the given http request and fills the given http response. -// This method will return an fiber.Handler +// This method will return a fiber.Handler func Forward(addr string, clients ...*fasthttp.Client) fiber.Handler { return func(c fiber.Ctx) error { return Do(c, addr, clients...) @@ -210,7 +210,7 @@ func getScheme(uri []byte) []byte { } // DomainForward performs an http request based on the given domain and populates the given http response. -// This method will return an fiber.Handler +// This method will return a fiber.Handler func DomainForward(hostname, addr string, clients ...*fasthttp.Client) fiber.Handler { return func(c fiber.Ctx) error { host := string(c.Request().Host()) @@ -243,7 +243,7 @@ func (r *roundrobin) get() string { } // BalancerForward Forward performs the given http request with round robin algorithm to server and fills the given http response. -// This method will return an fiber.Handler +// This method will return a fiber.Handler func BalancerForward(servers []string, clients ...*fasthttp.Client) fiber.Handler { r := &roundrobin{ current: 0, diff --git a/middleware/session/data_test.go b/middleware/session/data_test.go index 1913f761d3b..0551eb64c4c 100644 --- a/middleware/session/data_test.go +++ b/middleware/session/data_test.go @@ -140,14 +140,14 @@ func TestData_Len(t *testing.T) { func TestData_Get(t *testing.T) { t.Parallel() - // Test case: Non-existent key - t.Run("Non-existent key", func(t *testing.T) { + // Test case: Nonexistent key + t.Run("Nonexistent key", func(t *testing.T) { t.Parallel() d := acquireData() defer dataPool.Put(d) defer d.Reset() - value := d.Get("non-existent-key") - require.Nil(t, value, "Expected nil for non-existent key") + value := d.Get("nonexistent-key") + require.Nil(t, value, "Expected nil for nonexistent key") }) // Test case: Existing key @@ -192,13 +192,13 @@ func TestData_Delete(t *testing.T) { require.Nil(t, value, "Expected nil for deleted key") }) - // Test case: Delete non-existent key - t.Run("Delete non-existent key", func(t *testing.T) { + // Test case: Delete nonexistent key + t.Run("Delete nonexistent key", func(t *testing.T) { t.Parallel() d := acquireData() defer dataPool.Put(d) defer d.Reset() - d.Delete("non-existent-key") + d.Delete("nonexistent-key") // No assertion needed, just ensure no panic or error }) } diff --git a/middleware/session/middleware.go b/middleware/session/middleware.go index 75b0c2ec3f9..7c1f6989017 100644 --- a/middleware/session/middleware.go +++ b/middleware/session/middleware.go @@ -170,7 +170,7 @@ func releaseMiddleware(m *Middleware) { // - c: The Fiber context. // // Returns: -// - *Middleware: The middleware object if found, otherwise nil. +// - *Middleware: The middleware object if found; otherwise, nil. // // Usage: // @@ -267,7 +267,7 @@ func (m *Middleware) Destroy() error { // Fresh checks if the session is fresh. // // Returns: -// - bool: True if the session is fresh, otherwise false. +// - bool: True if the session is fresh; otherwise, false. // // Usage: // diff --git a/middleware/session/session.go b/middleware/session/session.go index a3beed2c97e..00bc13679af 100644 --- a/middleware/session/session.go +++ b/middleware/session/session.go @@ -102,7 +102,7 @@ func releaseSession(s *Session) { // Fresh returns whether the session is new // // Returns: -// - bool: True if the session is fresh, otherwise false. +// - bool: True if the session is fresh; otherwise, false. // // Usage: // @@ -562,7 +562,7 @@ func (s *Session) absExpiration() time.Time { // current time is after the absolute expiration time. // // Returns: -// - bool: True if the session is expired, otherwise false. +// - bool: True if the session is expired; otherwise, false. func (s *Session) isAbsExpired() bool { absExpiration := s.absExpiration() return !absExpiration.IsZero() && time.Now().After(absExpiration) diff --git a/middleware/session/store.go b/middleware/session/store.go index a5affa267a0..4719528af94 100644 --- a/middleware/session/store.go +++ b/middleware/session/store.go @@ -266,7 +266,7 @@ func (s *Store) Delete(ctx context.Context, id string) error { // - id: The unique identifier of the session. // // Returns: -// - *Session: The session object if found, otherwise nil. +// - *Session: The session object if found; otherwise, nil. // - error: An error if the session retrieval fails or if the session ID is empty. // // Usage: diff --git a/middleware/session/store_test.go b/middleware/session/store_test.go index 87ef25645b3..24428d56510 100644 --- a/middleware/session/store_test.go +++ b/middleware/session/store_test.go @@ -176,9 +176,9 @@ func Test_Store_GetByID(t *testing.T) { require.Equal(t, ErrEmptySessionID, err) }) - t.Run("non-existent session ID", func(t *testing.T) { + t.Run("nonexistent session ID", func(t *testing.T) { t.Parallel() - sess, err := store.GetByID(context.Background(), "non-existent-session-id") + sess, err := store.GetByID(context.Background(), "nonexistent-session-id") require.Error(t, err) require.Nil(t, sess) require.Equal(t, ErrSessionIDNotFoundInStore, err) diff --git a/middleware/static/static.go b/middleware/static/static.go index e6a4730173d..7b33fdf82a5 100644 --- a/middleware/static/static.go +++ b/middleware/static/static.go @@ -79,7 +79,7 @@ func sanitizePath(p []byte, filesystem fs.FS) ([]byte, error) { // New creates a new middleware handler. // The root argument specifies the root directory from which to serve static assets. // -// Note: Root has to be string or fs.FS, otherwise it will panic. +// Note: Root has to be string or fs.FS; otherwise, it will panic. func New(root string, cfg ...Config) fiber.Handler { config := configDefault(cfg...) diff --git a/middleware/static/static_test.go b/middleware/static/static_test.go index 068037f9955..d81dabd960d 100644 --- a/middleware/static/static_test.go +++ b/middleware/static/static_test.go @@ -1097,7 +1097,7 @@ func Test_Static_PathTraversal_WindowsOnly(t *testing.T) { // Attempt that includes a null-byte on Windows assertTraversalBlocked("/index.html%00.txt") - // Check behavior on an obviously non-existent and suspicious file + // Check behavior on an obviously nonexistent and suspicious file assertTraversalBlocked("/\\this\\path\\does\\not\\exist\\..") // Attempts involving relative traversal and current directory reference diff --git a/mount.go b/mount.go index 0b1a0f5d5bd..687063c2bcd 100644 --- a/mount.go +++ b/mount.go @@ -1,5 +1,5 @@ // ⚡️ Fiber is an Express inspired web framework written in Go with ☕️ -// 🤖 Github Repository: https://github.com/gofiber/fiber +// 🤖 GitHub Repository: https://github.com/gofiber/fiber // 📌 API Documentation: https://docs.gofiber.io package fiber diff --git a/mount_test.go b/mount_test.go index bc32f005458..2c3878165b2 100644 --- a/mount_test.go +++ b/mount_test.go @@ -1,5 +1,5 @@ // ⚡️ Fiber is an Express inspired web framework written in Go with ☕️ -// 🤖 Github Repository: https://github.com/gofiber/fiber +// 🤖 GitHub Repository: https://github.com/gofiber/fiber // 📌 API Documentation: https://docs.gofiber.io package fiber @@ -167,7 +167,7 @@ func Test_App_Mount_RoutePositions(t *testing.T) { return c.SendString("ok") }) app.Use(func(c Ctx) error { - // is overwritten in case the positioning is not correct + // is overwritten when the positioning is not correct c.Locals("world", "hello") return c.Next() }) diff --git a/path.go b/path.go index 5781fdfbf82..be6068017e7 100644 --- a/path.go +++ b/path.go @@ -1,5 +1,5 @@ // ⚡️ Fiber is an Express inspired web framework written in Go with ☕️ -// 📄 Github Repository: https://github.com/gofiber/fiber +// 📄 GitHub Repository: https://github.com/gofiber/fiber // 📌 API Documentation: https://docs.gofiber.io // ⚠️ This path parser was inspired by ucarion/urlpath (MIT License). // 💖 Maintained and modified for Fiber by @renewerner87 @@ -258,12 +258,12 @@ func addParameterMetaInfo(segs []*routeSegment) []*routeSegment { } } - // loop from begin to end + // loop from beginning to end for i := range segLen { // check how often the compare part is in the following const parts if segs[i].IsParam { - // check if parameter segments are directly after each other and if one of them is greedy - // in case the next parameter or the current parameter is not a wildcard it's not greedy, we only want one character + // check if parameter segments are directly after each other; + // when neither this parameter nor the next parameter are greedy, we only want one character if segLen > i+1 && !segs[i].IsGreedy && segs[i+1].IsParam && !segs[i+1].IsGreedy { segs[i].Length = 1 } diff --git a/path_test.go b/path_test.go index 6a9dc77b6dc..3290e58ebd9 100644 --- a/path_test.go +++ b/path_test.go @@ -1,5 +1,5 @@ // ⚡️ Fiber is an Express inspired web framework written in Go with ☕️ -// 📝 Github Repository: https://github.com/gofiber/fiber +// 📝 GitHub Repository: https://github.com/gofiber/fiber // 📌 API Documentation: https://docs.gofiber.io package fiber diff --git a/path_testcases_test.go b/path_testcases_test.go index bb6e2e831ee..593363c6219 100644 --- a/path_testcases_test.go +++ b/path_testcases_test.go @@ -1,5 +1,5 @@ // ⚡️ Fiber is an Express inspired web framework written in Go with ☕️ -// 📝 Github Repository: https://github.com/gofiber/fiber +// 📝 GitHub Repository: https://github.com/gofiber/fiber // 📌 API Documentation: https://docs.gofiber.io package fiber @@ -248,7 +248,7 @@ func init() { {url: "/fooba", params: nil, match: false}, }, }, - // chars in front of an parameter + // chars in front of a parameter { pattern: "/name::name", testCases: []routeTestCase{ @@ -350,7 +350,7 @@ func init() { {url: "/partialCheck/foo/bar/test", params: []string{"test"}, match: true, partialCheck: true}, {url: "/partialCheck/foo/bar/test/test2", params: []string{"test"}, match: true, partialCheck: true}, {url: "/partialCheck/foo/bar", params: nil, match: false, partialCheck: true}, - {url: "/partiaFoo", params: nil, match: false, partialCheck: true}, + {url: "/partialFoo", params: nil, match: false, partialCheck: true}, }, }, { diff --git a/prefork_test.go b/prefork_test.go index 2ad700ca24f..cff6e125f74 100644 --- a/prefork_test.go +++ b/prefork_test.go @@ -1,5 +1,5 @@ // ⚡️ Fiber is an Express inspired web framework written in Go with ☕️ -// 📄 Github Repository: https://github.com/gofiber/fiber +// 📄 GitHub Repository: https://github.com/gofiber/fiber // 📌 API Documentation: https://docs.gofiber.io // 💖 Maintained and modified for Fiber by @renewerner87 package fiber diff --git a/redirect.go b/redirect.go index ac17c48b343..a0b512c1969 100644 --- a/redirect.go +++ b/redirect.go @@ -1,5 +1,5 @@ // ⚡️ Fiber is an Express inspired web framework written in Go with ☕️ -// 📝 Github Repository: https://github.com/gofiber/fiber +// 📝 GitHub Repository: https://github.com/gofiber/fiber // 📌 API Documentation: https://docs.gofiber.io package fiber @@ -85,7 +85,7 @@ func AcquireRedirect() *Redirect { // ReleaseRedirect returns c acquired via Redirect to redirect pool. // -// It is forbidden accessing req and/or its' members after returning +// It is forbidden accessing req and/or its members after returning // it to redirect pool. func ReleaseRedirect(r *Redirect) { r.release() diff --git a/redirect_test.go b/redirect_test.go index 89e01127024..2ffef1cd6c1 100644 --- a/redirect_test.go +++ b/redirect_test.go @@ -1,5 +1,5 @@ // ⚡️ Fiber is an Express inspired web framework written in Go with ☕️ -// 📝 Github Repository: https://github.com/gofiber/fiber +// 📝 GitHub Repository: https://github.com/gofiber/fiber // 📌 API Documentation: https://docs.gofiber.io package fiber diff --git a/register.go b/register.go index 65e5acd84f9..edb8587dad0 100644 --- a/register.go +++ b/register.go @@ -1,5 +1,5 @@ // ⚡️ Fiber is an Express inspired web framework written in Go with ☕️ -// 🤖 Github Repository: https://github.com/gofiber/fiber +// 🤖 GitHub Repository: https://github.com/gofiber/fiber // 📌 API Documentation: https://docs.gofiber.io package fiber diff --git a/req.go b/req.go index 834649764ef..9084b03222e 100644 --- a/req.go +++ b/req.go @@ -317,7 +317,7 @@ func (r *DefaultReq) GetHeaders() map[string][]string { // while `Hostname` refers specifically to the name assigned to a device on a network, excluding any port information. // Example: URL: https://example.com:8080 -> Host: example.com:8080 // Make copies or use the Immutable setting instead. -// Please use Config.TrustProxy to prevent header spoofing, in case when your app is behind the proxy. +// Please use Config.TrustProxy to prevent header spoofing if your app is behind a proxy. func (r *DefaultReq) Host() string { if r.IsProxyTrusted() { if host := r.Get(HeaderXForwardedHost); len(host) > 0 { @@ -335,7 +335,7 @@ func (r *DefaultReq) Host() string { // Returned value is only valid within the handler. Do not store any references. // Example: URL: https://example.com:8080 -> Hostname: example.com // Make copies or use the Immutable setting instead. -// Please use Config.TrustProxy to prevent header spoofing, in case when your app is behind the proxy. +// Please use Config.TrustProxy to prevent header spoofing if your app is behind a proxy. func (r *DefaultReq) Hostname() string { addr, _ := parseAddr(r.Host()) @@ -353,7 +353,7 @@ func (r *DefaultReq) Port() string { // IP returns the remote IP address of the request. // If ProxyHeader and IP Validation is configured, it will parse that header and return the first valid IP address. -// Please use Config.TrustProxy to prevent header spoofing, in case when your app is behind the proxy. +// Please use Config.TrustProxy to prevent header spoofing if your app is behind a proxy. func (r *DefaultReq) IP() string { app := r.c.app if r.IsProxyTrusted() && len(app.config.ProxyHeader) > 0 { @@ -412,7 +412,7 @@ iploop: s := utils.TrimRight(headerValue[i:j], ' ') if r.c.app.config.EnableIPValidation { - // Skip validation if IP is clearly not IPv4/IPv6, otherwise validate without allocations + // Skip validation if IP is clearly not IPv4/IPv6; otherwise, validate without allocations if (!v6 && !v4) || (v6 && !utils.IsIPv6(s)) || (v4 && !utils.IsIPv4(s)) { continue iploop } @@ -560,7 +560,7 @@ func (r *DefaultReq) Method(override ...string) string { } // MultipartForm parse form entries from binary. -// This returns a map[string][]string, so given a key the value will be a string slice. +// This returns a map[string][]string, so given a key, the value will be a string slice. func (r *DefaultReq) MultipartForm() (*multipart.Form, error) { return r.c.fasthttp.MultipartForm() } @@ -590,7 +590,7 @@ func (r *DefaultReq) Params(key string, defaultValue ...string) string { continue } if route.Params[i] == key || (!app.config.CaseSensitive && utils.EqualFold(route.Params[i], key)) { - // in case values are not here + // if there is no value for the key if len(values) <= i || len(values[i]) == 0 { break } @@ -625,7 +625,7 @@ func Params[V GenericType](c Ctx, key string, defaultValue ...V) V { } // Scheme contains the request protocol string: http or https for TLS requests. -// Please use Config.TrustProxy to prevent header spoofing, in case when your app is behind the proxy. +// Please use Config.TrustProxy to prevent header spoofing if your app is behind a proxy. func (r *DefaultReq) Scheme() string { ctx := r.c.fasthttp if ctx.IsTLS() { @@ -717,7 +717,7 @@ func (r *DefaultReq) Queries() map[string]string { // It takes the following parameters: // - c: The context object representing the current request. // - key: The name of the query parameter. -// - defaultValue: (Optional) The default value to return in case the query parameter is not found or cannot be parsed. +// - defaultValue: (Optional) The default value to return if the query parameter is not found or cannot be parsed. // The function performs the following steps: // 1. Type-asserts the context object to *DefaultCtx. // 2. Retrieves the raw query parameter value from the request's URI. diff --git a/req_interface_gen.go b/req_interface_gen.go index 77b5549719a..1ecd257951c 100644 --- a/req_interface_gen.go +++ b/req_interface_gen.go @@ -81,19 +81,19 @@ type Req interface { // while `Hostname` refers specifically to the name assigned to a device on a network, excluding any port information. // Example: URL: https://example.com:8080 -> Host: example.com:8080 // Make copies or use the Immutable setting instead. - // Please use Config.TrustProxy to prevent header spoofing, in case when your app is behind the proxy. + // Please use Config.TrustProxy to prevent header spoofing if your app is behind a proxy. Host() string // Hostname contains the hostname derived from the X-Forwarded-Host or Host HTTP header using the c.Host() method. // Returned value is only valid within the handler. Do not store any references. // Example: URL: https://example.com:8080 -> Hostname: example.com // Make copies or use the Immutable setting instead. - // Please use Config.TrustProxy to prevent header spoofing, in case when your app is behind the proxy. + // Please use Config.TrustProxy to prevent header spoofing if your app is behind a proxy. Hostname() string // Port returns the remote port of the request. Port() string // IP returns the remote IP address of the request. // If ProxyHeader and IP Validation is configured, it will parse that header and return the first valid IP address. - // Please use Config.TrustProxy to prevent header spoofing, in case when your app is behind the proxy. + // Please use Config.TrustProxy to prevent header spoofing if your app is behind a proxy. IP() string // extractIPsFromHeader will return a slice of IPs it found given a header name in the order they appear. // When IP validation is enabled, any invalid IPs will be omitted. @@ -121,7 +121,7 @@ type Req interface { // Otherwise, it updates the context's method and returns the overridden method as a string. Method(override ...string) string // MultipartForm parse form entries from binary. - // This returns a map[string][]string, so given a key the value will be a string slice. + // This returns a map[string][]string, so given a key, the value will be a string slice. MultipartForm() (*multipart.Form, error) // OriginalURL contains the original request URL. // Returned value is only valid within the handler. Do not store any references. @@ -134,7 +134,7 @@ type Req interface { // Make copies or use the Immutable setting to use the value outside the Handler. Params(key string, defaultValue ...string) string // Scheme contains the request protocol string: http or https for TLS requests. - // Please use Config.TrustProxy to prevent header spoofing, in case when your app is behind the proxy. + // Please use Config.TrustProxy to prevent header spoofing if your app is behind a proxy. Scheme() string // Protocol returns the HTTP protocol of request: HTTP/1.1 and HTTP/2. Protocol() string diff --git a/res.go b/res.go index 05251a8831b..dc9c3f83dec 100644 --- a/res.go +++ b/res.go @@ -947,7 +947,7 @@ func shouldIncludeCharset(mimeType string) bool { } // Vary adds the given header field to the Vary response header. -// This will append the header, if not already listed, otherwise leaves it listed in the current location. +// This will append the header, if not already listed; otherwise, leaves it listed in the current location. func (r *DefaultRes) Vary(fields ...string) { r.Append(HeaderVary, fields...) } diff --git a/res_interface_gen.go b/res_interface_gen.go index b8c014e9a1a..b4a90590734 100644 --- a/res_interface_gen.go +++ b/res_interface_gen.go @@ -144,7 +144,7 @@ type Res interface { // Type sets the Content-Type HTTP header to the MIME type specified by the file extension. Type(extension string, charset ...string) Ctx // Vary adds the given header field to the Vary response header. - // This will append the header, if not already listed, otherwise leaves it listed in the current location. + // This will append the header, if not already listed; otherwise, leaves it listed in the current location. Vary(fields ...string) // Write appends p into response body. Write(p []byte) (int, error) diff --git a/router.go b/router.go index 084375bc7e5..d69170266bb 100644 --- a/router.go +++ b/router.go @@ -1,5 +1,5 @@ // ⚡️ Fiber is an Express inspired web framework written in Go with ☕️ -// 🤖 Github Repository: https://github.com/gofiber/fiber +// 🤖 GitHub Repository: https://github.com/gofiber/fiber // 📌 API Documentation: https://docs.gofiber.io package fiber diff --git a/router_test.go b/router_test.go index 4bc7feb6e17..e2ef1613c5e 100644 --- a/router_test.go +++ b/router_test.go @@ -1,5 +1,5 @@ // ⚡️ Fiber is an Express inspired web framework written in Go with ☕️ -// 📃 Github Repository: https://github.com/gofiber/fiber +// 📃 GitHub Repository: https://github.com/gofiber/fiber // 📌 API Documentation: https://docs.gofiber.io package fiber @@ -1204,7 +1204,7 @@ func registerDummyRoutes(app *App) { h := func(_ Ctx) error { return nil } - for _, r := range routesFixture.GithubAPI { + for _, r := range routesFixture.GitHubAPI { app.Add([]string{r.Method}, r.Path, h) } } @@ -1589,8 +1589,8 @@ func Benchmark_Router_Handler_StrictRouting(b *testing.B) { } } -// go test -run=^$ -bench=Benchmark_Router_Github_API -benchmem -count=16 -func Benchmark_Router_Github_API(b *testing.B) { +// go test -run=^$ -bench=Benchmark_Router_GitHub_API -benchmem -count=16 +func Benchmark_Router_GitHub_API(b *testing.B) { app := New() registerDummyRoutes(app) app.startupProcess() @@ -1625,7 +1625,7 @@ type testRoute struct { type routeJSON struct { TestRoutes []testRoute `json:"test_routes"` - GithubAPI []testRoute `json:"github_api"` + GitHubAPI []testRoute `json:"github_api"` } func newCustomApp() *App { diff --git a/state_test.go b/state_test.go index dd703ed50c3..c4544ec63a4 100644 --- a/state_test.go +++ b/state_test.go @@ -743,7 +743,7 @@ func BenchmarkState_Get(b *testing.B) { st := newState() n := 1000 - // pre-populate the state + // prepopulate the state for i := range n { key := "key" + strconv.Itoa(i) st.Set(key, i) @@ -762,7 +762,7 @@ func BenchmarkState_GetString(b *testing.B) { st := newState() n := 1000 - // pre-populate the state + // prepopulate the state for i := range n { key := "key" + strconv.Itoa(i) st.Set(key, strconv.Itoa(i)) @@ -781,7 +781,7 @@ func BenchmarkState_GetInt(b *testing.B) { st := newState() n := 1000 - // pre-populate the state + // prepopulate the state for i := range n { key := "key" + strconv.Itoa(i) st.Set(key, i) @@ -800,7 +800,7 @@ func BenchmarkState_GetBool(b *testing.B) { st := newState() n := 1000 - // pre-populate the state + // prepopulate the state for i := range n { key := "key" + strconv.Itoa(i) st.Set(key, i%2 == 0) @@ -819,7 +819,7 @@ func BenchmarkState_GetFloat64(b *testing.B) { st := newState() n := 1000 - // pre-populate the state + // prepopulate the state for i := range n { key := "key" + strconv.Itoa(i) st.Set(key, float64(i)) @@ -838,7 +838,7 @@ func BenchmarkState_MustGet(b *testing.B) { st := newState() n := 1000 - // pre-populate the state + // prepopulate the state for i := range n { key := "key" + strconv.Itoa(i) st.Set(key, i) @@ -857,7 +857,7 @@ func BenchmarkState_GetStateGeneric(b *testing.B) { st := newState() n := 1000 - // pre-populate the state + // prepopulate the state for i := range n { key := "key" + strconv.Itoa(i) st.Set(key, i) @@ -876,7 +876,7 @@ func BenchmarkState_MustGetStateGeneric(b *testing.B) { st := newState() n := 1000 - // pre-populate the state + // prepopulate the state for i := range n { key := "key" + strconv.Itoa(i) st.Set(key, i) @@ -895,7 +895,7 @@ func BenchmarkState_GetStateWithDefault(b *testing.B) { st := newState() n := 1000 - // pre-populate the state + // prepopulate the state for i := range n { key := "key" + strconv.Itoa(i) st.Set(key, i) @@ -914,7 +914,7 @@ func BenchmarkState_Has(b *testing.B) { st := newState() n := 1000 - // pre-populate the state + // prepopulate the state for i := range n { st.Set("key"+strconv.Itoa(i), i) } @@ -981,7 +981,7 @@ func BenchmarkState_GetUint(b *testing.B) { b.ReportAllocs() st := newState() n := 1000 - // Pre-populate the state with uint values. + // Prepopulate the state with uint values. for i := range n { key := "key" + strconv.Itoa(i) st.Set(key, uint(i)) //nolint:gosec // This is a test @@ -998,7 +998,7 @@ func BenchmarkState_GetInt8(b *testing.B) { b.ReportAllocs() st := newState() n := 1000 - // Pre-populate the state with int8 values (using modulo to stay in range). + // Prepopulate the state with int8 values (using modulo to stay in range). for i := range n { key := "key" + strconv.Itoa(i) st.Set(key, int8(i%128)) //nolint:gosec // This is a test @@ -1015,7 +1015,7 @@ func BenchmarkState_GetInt16(b *testing.B) { b.ReportAllocs() st := newState() n := 1000 - // Pre-populate the state with int16 values. + // Prepopulate the state with int16 values. for i := range n { key := "key" + strconv.Itoa(i) st.Set(key, int16(i)) //nolint:gosec // This is a test @@ -1032,7 +1032,7 @@ func BenchmarkState_GetInt32(b *testing.B) { b.ReportAllocs() st := newState() n := 1000 - // Pre-populate the state with int32 values. + // Prepopulate the state with int32 values. for i := range n { key := "key" + strconv.Itoa(i) st.Set(key, int32(i)) //nolint:gosec // This is a test @@ -1049,7 +1049,7 @@ func BenchmarkState_GetInt64(b *testing.B) { b.ReportAllocs() st := newState() n := 1000 - // Pre-populate the state with int64 values. + // Prepopulate the state with int64 values. for i := range n { key := "key" + strconv.Itoa(i) st.Set(key, int64(i)) @@ -1066,7 +1066,7 @@ func BenchmarkState_GetUint8(b *testing.B) { b.ReportAllocs() st := newState() n := 1000 - // Pre-populate the state with uint8 values. + // Prepopulate the state with uint8 values. for i := range n { key := "key" + strconv.Itoa(i) st.Set(key, uint8(i%256)) //nolint:gosec // This is a test @@ -1083,7 +1083,7 @@ func BenchmarkState_GetUint16(b *testing.B) { b.ReportAllocs() st := newState() n := 1000 - // Pre-populate the state with uint16 values. + // Prepopulate the state with uint16 values. for i := range n { key := "key" + strconv.Itoa(i) st.Set(key, uint16(i)) //nolint:gosec // This is a test @@ -1100,7 +1100,7 @@ func BenchmarkState_GetUint32(b *testing.B) { b.ReportAllocs() st := newState() n := 1000 - // Pre-populate the state with uint32 values. + // Prepopulate the state with uint32 values. for i := range n { key := "key" + strconv.Itoa(i) st.Set(key, uint32(i)) //nolint:gosec // This is a test @@ -1117,7 +1117,7 @@ func BenchmarkState_GetUint64(b *testing.B) { b.ReportAllocs() st := newState() n := 1000 - // Pre-populate the state with uint64 values. + // Prepopulate the state with uint64 values. for i := range n { key := "key" + strconv.Itoa(i) st.Set(key, uint64(i)) //nolint:gosec // This is a test @@ -1134,7 +1134,7 @@ func BenchmarkState_GetUintptr(b *testing.B) { b.ReportAllocs() st := newState() n := 1000 - // Pre-populate the state with uintptr values. + // Prepopulate the state with uintptr values. for i := range n { key := "key" + strconv.Itoa(i) st.Set(key, uintptr(i)) @@ -1151,7 +1151,7 @@ func BenchmarkState_GetFloat32(b *testing.B) { b.ReportAllocs() st := newState() n := 1000 - // Pre-populate the state with float32 values. + // Prepopulate the state with float32 values. for i := range n { key := "key" + strconv.Itoa(i) st.Set(key, float32(i)) @@ -1168,7 +1168,7 @@ func BenchmarkState_GetComplex64(b *testing.B) { b.ReportAllocs() st := newState() n := 1000 - // Pre-populate the state with complex64 values. + // Prepopulate the state with complex64 values. for i := range n { key := "key" + strconv.Itoa(i) // Create a complex64 value with both real and imaginary parts. @@ -1186,7 +1186,7 @@ func BenchmarkState_GetComplex128(b *testing.B) { b.ReportAllocs() st := newState() n := 1000 - // Pre-populate the state with complex128 values. + // Prepopulate the state with complex128 values. for i := range n { key := "key" + strconv.Itoa(i) // Create a complex128 value with both real and imaginary parts.