Skip to content

Commit

Permalink
Add 404 HTTP handlers to prevent those requests going to BasicAuth en…
Browse files Browse the repository at this point in the history
…dpoints.
  • Loading branch information
knadh committed Nov 25, 2023
1 parent 5f78f2e commit d90ee96
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/dictpress/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,17 @@ func initHTTPServer(app *App, ko *koanf.Koanf) *echo.Echo {
a.PUT("/api/entries/:id/submission", handleApproveSubmission)
a.DELETE("/api/entries/:id/submission", handleRejectSubmission)

// 404 pages.
srv.RouteNotFound("/api/*", func(c echo.Context) error {
return echo.NewHTTPError(http.StatusNotFound, "Unknown endpoint")
})
srv.RouteNotFound("/*", func(c echo.Context) error {
return c.Render(http.StatusNotFound, "message", pageTpl{
Title: "404 Page not found",
Heading: "404 Page not found",
})
})

return srv
}

Expand Down

0 comments on commit d90ee96

Please sign in to comment.