Skip to content

Commit

Permalink
Use default rate limiter error handlers to fix responses (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
muXxer authored Feb 27, 2023
1 parent fb0517f commit b513f55
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion core/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var (
Name = "inx-faucet"

// Version of the app.
Version = "1.0.0-rc.2"
Version = "1.0.0-rc.3"
)

func App() *app.App {
Expand Down
2 changes: 1 addition & 1 deletion core/faucet/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func frontendMiddleware() echo.MiddlewareFunc {
return func(c echo.Context) error {
contentType := calculateMimeType(c)

path := strings.TrimPrefix(c.Request().URL.Path, "/")
path := strings.TrimPrefix(c.Request().RequestURI, "/")
if len(path) == 0 {
path = "index.html"
contentType = echo.MIMETextHTMLCharsetUTF8
Expand Down
8 changes: 1 addition & 7 deletions core/faucet/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const (

func enforceMaxOneDotPerURL(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
if strings.Count(c.Request().URL.Path, "..") != 0 {
if strings.Count(c.Request().RequestURI, "..") != 0 {
return c.String(http.StatusForbidden, "path not allowed")
}

Expand Down Expand Up @@ -93,12 +93,6 @@ func setupRoutes(e *echo.Echo) {

return id, nil
},
ErrorHandler: func(context echo.Context, err error) error {
return context.JSON(http.StatusForbidden, nil)
},
DenyHandler: func(context echo.Context, identifier string, err error) error {
return context.JSON(http.StatusTooManyRequests, nil)
},
}
apiGroup.Use(middleware.RateLimiterWithConfig(rateLimiterConfig))
}
Expand Down

0 comments on commit b513f55

Please sign in to comment.