From 2b608b47256b1b688fc2c2cd3d533dc86791bb98 Mon Sep 17 00:00:00 2001 From: httpjamesm Date: Sat, 4 Feb 2023 12:49:28 -0500 Subject: [PATCH] feat: redirect questions without title in URL --- main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index a0a7682..bcf1332 100644 --- a/main.go +++ b/main.go @@ -47,9 +47,12 @@ func main() { r.GET("/options/:name", routes.ChangeOptions) r.GET("/", routes.GetHome) - r.POST("/", routes.PostHome) + r.GET("/questions/:id", func(c *gin.Context) { + // redirect user to the question with the title + c.Redirect(302, fmt.Sprintf("/questions/%s/placeholder", c.Param("id"))) + }) r.GET("/questions/:id/:title", routes.ViewQuestion) r.GET("/proxy", routes.GetImage)