bskyweb: middleware to remove trailing / (#598)

zio/stable
bnewbold 2023-05-09 10:03:42 -07:00 committed by GitHub
parent bf3ea67442
commit 9a91b0c538
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -92,6 +92,12 @@ func serve(cctx *cli.Context) error {
e.Renderer = NewRenderer("templates/", &bskyweb.TemplateFS, debug) e.Renderer = NewRenderer("templates/", &bskyweb.TemplateFS, debug)
e.HTTPErrorHandler = customHTTPErrorHandler e.HTTPErrorHandler = customHTTPErrorHandler
// redirect trailing slash to non-trailing slash.
// all of our current endpoints have no trailing slash.
e.Use(middleware.RemoveTrailingSlashWithConfig(middleware.TrailingSlashConfig{
RedirectCode: http.StatusFound,
}))
// configure routes // configure routes
e.GET("/robots.txt", echo.WrapHandler(staticHandler)) e.GET("/robots.txt", echo.WrapHandler(staticHandler))
e.GET("/static/*", echo.WrapHandler(http.StripPrefix("/static/", staticHandler))) e.GET("/static/*", echo.WrapHandler(http.StripPrefix("/static/", staticHandler)))