about summary refs log tree commit diff
path: root/bskyweb/cmd
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2023-05-09 10:03:42 -0700
committerGitHub <noreply@github.com>2023-05-09 12:03:42 -0500
commit9a91b0c538e3c24a25285ae2bdf1d0dfd2ba53a4 (patch)
treef007900f1903d1eeac9e292cc7d1f15a2f05e26c /bskyweb/cmd
parentbf3ea67442857b62d29c74ba0739f31a79b0f7b7 (diff)
downloadvoidsky-9a91b0c538e3c24a25285ae2bdf1d0dfd2ba53a4.tar.zst
bskyweb: middleware to remove trailing / (#598)
Diffstat (limited to 'bskyweb/cmd')
-rw-r--r--bskyweb/cmd/bskyweb/server.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/bskyweb/cmd/bskyweb/server.go b/bskyweb/cmd/bskyweb/server.go
index 25ae5cc3f..5ba1dbc80 100644
--- a/bskyweb/cmd/bskyweb/server.go
+++ b/bskyweb/cmd/bskyweb/server.go
@@ -92,6 +92,12 @@ func serve(cctx *cli.Context) error {
 	e.Renderer = NewRenderer("templates/", &bskyweb.TemplateFS, debug)
 	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
 	e.GET("/robots.txt", echo.WrapHandler(staticHandler))
 	e.GET("/static/*", echo.WrapHandler(http.StripPrefix("/static/", staticHandler)))