mirror of
https://github.com/gofiber/fiber.git
synced 2025-02-23 01:23:43 +00:00
v1.9.3
This commit is contained in:
parent
e5e887f9e0
commit
2267f8790c
2
.github/.gitpod.yml
vendored
2
.github/.gitpod.yml
vendored
@ -1,2 +0,0 @@
|
||||
tasks:
|
||||
- init: go get && go build ./... && go test ./...
|
1
.github/CNAME
vendored
1
.github/CNAME
vendored
@ -1 +0,0 @@
|
||||
fiber.wiki
|
3
app.go
3
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
|
||||
|
@ -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)
|
||||
|
6
ctx.go
6
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
|
||||
|
@ -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()
|
||||
|
4
utils.go
4
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user