add middleware
This commit is contained in:
parent
ecf852cedd
commit
5d746323c1
@ -3,12 +3,25 @@ package main
|
||||
import (
|
||||
"git.keircn.com/keiran/termcloud/internal/handlers"
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/labstack/echo/v4/middleware"
|
||||
"golang.org/x/time/rate"
|
||||
)
|
||||
|
||||
func main() {
|
||||
e := echo.New()
|
||||
|
||||
e.Use(middleware.BodyLimit("100M"))
|
||||
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
|
||||
AllowOrigins: []string{"*"},
|
||||
AllowMethods: []string{echo.GET, echo.POST},
|
||||
}))
|
||||
e.Use(middleware.GzipWithConfig(middleware.GzipConfig{
|
||||
Level: 5,
|
||||
}))
|
||||
e.Use(middleware.RateLimiter(middleware.NewRateLimiterMemoryStore(rate.Limit(20))))
|
||||
|
||||
e.GET("/", handlers.RootHandler)
|
||||
e.POST("/upload", handlers.UploadHandler)
|
||||
|
||||
e.Logger.Fatal(e.Start(":8080"))
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user