diff --git a/.github/.gitpod.yml b/.github/.gitpod.yml deleted file mode 100644 index f1e44ef1..00000000 --- a/.github/.gitpod.yml +++ /dev/null @@ -1,2 +0,0 @@ -tasks: - - init: go get && go build ./... && go test ./... diff --git a/.github/CNAME b/.github/CNAME deleted file mode 100644 index 862e8d01..00000000 --- a/.github/CNAME +++ /dev/null @@ -1 +0,0 @@ -fiber.wiki \ No newline at end of file diff --git a/app.go b/app.go index 422febbb..35d9b6bb 100644 --- a/app.go +++ b/app.go @@ -48,7 +48,8 @@ type Settings struct { ServerHeader string // default: "" // Enables handler values to be immutable even if you return from handler Immutable bool // default: false - // Enable or disable ETag header generation + // Enable or disable ETag header generation, since both weak and strong etags are generated + // using the same hashing method (CRC-32). Weak ETags are the default when enabled. // Optional. Default value false ETag bool // Max body size that the server accepts diff --git a/app_test.go b/app_test.go index 949336bb..d88c9089 100644 --- a/app_test.go +++ b/app_test.go @@ -96,7 +96,7 @@ func Test_Static(t *testing.T) { DisableStartupMessage: true, }) grp := app.Group("/v1") - grp.Static("/v2", ".travis.yml") + grp.Static("/v2", ".github/auth_assign.yml") app.Static("/*", ".github/FUNDING.yml") app.Static("/john", "./.github") req, _ := http.NewRequest("GET", "/john/stale.yml", nil) diff --git a/ctx.go b/ctx.go index 846e2d32..b812910d 100644 --- a/ctx.go +++ b/ctx.go @@ -409,7 +409,11 @@ func (ctx *Ctx) FormValue(key string) (value string) { return getString(ctx.Fasthttp.FormValue(key)) } -// Fresh is not implemented yet, pull requests are welcome! +// 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 a client sends the Cache-Control: no-cache request header to indicate an end-to-end +// reload request, this module will return false to make handling these requests transparent. // https://github.com/jshttp/fresh/blob/10e0471669dbbfbfd8de65bc6efac2ddd0bfa057/index.js#L33 func (ctx *Ctx) Fresh() bool { // fields diff --git a/router.go b/router.go index c79b7f24..cee7e0e8 100644 --- a/router.go +++ b/router.go @@ -44,7 +44,7 @@ func (app *App) nextRoute(ctx *Ctx) { route.Handler(ctx) // Generate ETag if enabled / found if app.Settings.ETag { - getETag(ctx, ctx.Fasthttp.Response.Body(), false) + setETag(ctx, ctx.Fasthttp.Response.Body(), false) } return } @@ -266,13 +266,11 @@ func (app *App) registerStatic(prefix, root string, config ...Static) { } // Serve file fileHandler(c.Fasthttp) - // End response when file is found if c.Fasthttp.Response.StatusCode() != 404 { return } // Reset response - //c.Fasthttp.ResetBody() // Dit is iets anders c.Fasthttp.Response.Reset() } c.Next() diff --git a/utils.go b/utils.go index 3d6dd5aa..b18cd18f 100644 --- a/utils.go +++ b/utils.go @@ -18,7 +18,7 @@ import ( ) // Document elke line gelijk even -func getETag(ctx *Ctx, body []byte, weak bool) { +func setETag(ctx *Ctx, body []byte, weak bool) { // Skips ETag if no response body is present if len(body) <= 0 { return @@ -32,7 +32,7 @@ func getETag(ctx *Ctx, body []byte, weak bool) { // Enable weak tag if weak { - etag = "W/" + etag + etag = "W/" + "\"" + etag + "\"" } // Check if client's ETag is weak