Skip to content

Commit

Permalink
chore: take advantages of echo middlewares
Browse files Browse the repository at this point in the history
  • Loading branch information
jjacque committed Jul 10, 2024
1 parent afdab1c commit 1cf2f4f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion internal/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,17 @@ func Serve(cnf conf) {
e.AutoTLSManager.Cache = autocert.DirCache("/var/www/.cache")
}

e.Use(middleware.Logger())
// // Limit to 10 RPS (only human should use this service)
e.Use(middleware.RateLimiter(middleware.NewRateLimiterMemoryStore(10)))
// do not log the /health endpoint
e.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
Skipper: func(c echo.Context) bool {
return c.Path() == "/health"
},
}))
e.Use(middleware.BodyLimit("50M"))
e.Use(middleware.Secure())
e.Use(middleware.Recover())

e.GET("/", redirectHandler)
e.File("/robots.txt", "static/robots.txt")
Expand Down

0 comments on commit 1cf2f4f

Please sign in to comment.