Skip to content

Commit 8b5d605

Browse files
committed
[api] add E-Tag header for the docs
1 parent daaf522 commit 8b5d605

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

internal/api/module.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"github.com/android-sms-gateway/ca/pkg/core/http/jsonify"
66
"github.com/gofiber/fiber/v2"
77
"github.com/gofiber/fiber/v2/middleware/cors"
8+
"github.com/gofiber/fiber/v2/middleware/etag"
89
"github.com/gofiber/swagger"
910
"go.uber.org/fx"
1011
"go.uber.org/zap"
@@ -24,12 +25,17 @@ var Module = fx.Module(
2425
}),
2526
fx.Provide(newCSR, fx.Private),
2627
fx.Invoke(func(app *fiber.App, csr *csrHandler, config Config) {
27-
api := app.Group("/api/v1")
28-
2928
apidoc.SwaggerInfo.Version = version.AppVersion
30-
api.Get("/docs/*", swagger.New(swagger.Config{
31-
Layout: "BaseLayout",
32-
}))
29+
app.Use("/docs/*",
30+
etag.New(etag.Config{
31+
Weak: true,
32+
}),
33+
swagger.New(swagger.Config{
34+
Layout: "BaseLayout",
35+
}),
36+
)
37+
38+
api := app.Group("/api/v1")
3339

3440
if config.CORSAllowOrigins != "" {
3541
api.Use(cors.New(cors.Config{
@@ -43,7 +49,7 @@ var Module = fx.Module(
4349

4450
csr.Register(api.Group("csr"))
4551

46-
api.Use(func(ctx *fiber.Ctx) error {
52+
app.Use(func(ctx *fiber.Ctx) error {
4753
return ctx.SendStatus(fiber.StatusNotFound)
4854
})
4955
}),

0 commit comments

Comments
 (0)