Template
1
0
Fork 0

Update bunrouter.middleware to bmw

This commit is contained in:
Atridad Lahiji 2024-01-24 20:51:42 -07:00
parent b4aba437e5
commit 5a998183ee
No known key found for this signature in database
3 changed files with 6 additions and 6 deletions

2
go.mod
View file

@ -24,7 +24,7 @@ require (
require (
github.com/alecthomas/assert/v2 v2.4.1
github.com/atridadl/bunrouter.middleware v0.2.0
github.com/atridadl/bmw v0.1.0
github.com/go-redis/redismock/v9 v9.2.0
github.com/google/uuid v1.6.0 // indirect
github.com/joho/godotenv v1.5.1

4
go.sum
View file

@ -6,8 +6,8 @@ github.com/alecthomas/chroma/v2 v2.12.0/go.mod h1:4TQu7gdfuPjSh76j78ietmqh9LiurG
github.com/alecthomas/repr v0.0.0-20220113201626-b1b626ac65ae/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8=
github.com/alecthomas/repr v0.3.0 h1:NeYzUPfjjlqHY4KtzgKJiWd6sVq2eNUPTi34PiFGjY8=
github.com/alecthomas/repr v0.3.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
github.com/atridadl/bunrouter.middleware v0.2.0 h1:pEcQuYL9CJD/25Ff2ljtXfoDXgAo89iwndeeC4R0wJs=
github.com/atridadl/bunrouter.middleware v0.2.0/go.mod h1:ranjgPw1Y8Rds6sV5ZducCligVzhVukraOuVrD7EVBE=
github.com/atridadl/bmw v0.1.0 h1:PoW3s5n6IAmsfOyZpWSvMgaTCe9r7lttyuIbXXIMc3E=
github.com/atridadl/bmw v0.1.0/go.mod h1:LHXSDXKjmOvPXgDv32CDeu1nTmT+luIF+YR9xmqPvEw=
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=

View file

@ -9,7 +9,7 @@ import (
"goth.stack/api"
"goth.stack/pages"
bunroutermiddleware "github.com/atridadl/bunrouter.middleware"
bmw "github.com/atridadl/bmw"
"github.com/joho/godotenv"
"github.com/uptrace/bunrouter"
"github.com/uptrace/bunrouter/extra/reqlog"
@ -30,7 +30,7 @@ func main() {
// Initialize router
router := bunrouter.New(
bunrouter.Use(reqlog.NewMiddleware(), bunroutermiddleware.RequestID, bunroutermiddleware.SecureHeaders),
bunrouter.Use(reqlog.NewMiddleware(), bmw.RequestID, bmw.SecureHeaders),
)
// Static server
@ -42,7 +42,7 @@ func main() {
})
// Page routes
pageGroup := router.NewGroup("", bunrouter.Use(bunroutermiddleware.NewRateLimiter(50).RateLimit))
pageGroup := router.NewGroup("", bunrouter.Use(bmw.NewRateLimiter(50).RateLimit))
pageGroup.GET("/", pages.Home)
pageGroup.GET("/blog", pages.Blog)
pageGroup.GET("/post/:post", pages.Post)