Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Skip etag for the api #318

Merged
merged 1 commit into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion pkg/cmds/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

import (
"context"
"crypto/sha256"
"hash"
"hash/crc32"
"net/http"
"os"
"os/signal"
Expand Down Expand Up @@ -84,7 +87,27 @@
config := ptr.To(configs.GetConfiguration())

e.Use(middleware.CORS())
e.Use(middlewares.Etag())
e.Use(middlewares.WithEtagConfig(middlewares.EtagConfig{
Skipper: func(c echo.Context) bool {
reqPath := c.Request().URL.Path
if strings.HasPrefix(reqPath, "/api/v1/") {
return true
}
if strings.HasPrefix(reqPath, "/v2/") {
return true
}
return false

Check warning on line 99 in pkg/cmds/server/server.go

View check run for this annotation

Codecov / codecov/patch

pkg/cmds/server/server.go#L90-L99

Added lines #L90 - L99 were not covered by tests
},
Weak: true,
HashFn: func(config middlewares.EtagConfig) hash.Hash {
if config.Weak {
const crcPol = 0xD5828281
crc32qTable := crc32.MakeTable(crcPol)
return crc32.New(crc32qTable)
}
return sha256.New()

Check warning on line 108 in pkg/cmds/server/server.go

View check run for this annotation

Codecov / codecov/patch

pkg/cmds/server/server.go#L102-L108

Added lines #L102 - L108 were not covered by tests
},
}))
e.Use(echoprometheus.NewMiddleware(consts.AppName))
e.GET("/metrics", echoprometheus.NewHandler())
e.Use(middlewares.Healthz())
Expand Down
34 changes: 0 additions & 34 deletions scripts/offline-package.sh

This file was deleted.

15 changes: 0 additions & 15 deletions scripts/samples/restart.sh

This file was deleted.

28 changes: 0 additions & 28 deletions scripts/samples/start.sh

This file was deleted.

Loading