feat: change options

This commit is contained in:
httpjamesm
2022-12-28 00:08:06 -05:00
parent 8b46beb1dd
commit 10946dcafb
4 changed files with 36 additions and 1 deletions
+25
View File
@@ -0,0 +1,25 @@
package routes
import (
"fmt"
"github.com/gin-gonic/gin"
)
func ChangeOptions(c *gin.Context) {
name := c.Param("name")
switch name {
case "images":
text := "disabled"
if c.MustGet("disable_images").(bool) {
text = "enabled"
}
c.SetCookie("disable_images", fmt.Sprintf("%t", !c.MustGet("disable_images").(bool)), 60*60*24*365*10, "/", "", false, true)
c.String(200, "Images are now %s", text)
default:
c.String(400, "400 Bad Request")
}
c.Redirect(302, "/")
}