mirror of
https://github.com/httpjamesm/AnonymousOverflow.git
synced 2024-12-06 19:16:43 +01:00
feat: import theme icons, set color vars, option cookie
This commit is contained in:
@@ -5,19 +5,28 @@ import "github.com/gin-gonic/gin"
|
||||
func OptionsMiddleware() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
c.Set("disable_images", false)
|
||||
c.Set("theme", "dark")
|
||||
|
||||
// get cookie
|
||||
cookie, err := c.Cookie("disable_images")
|
||||
imagesCookie, err := c.Cookie("disable_images")
|
||||
if err != nil {
|
||||
c.Next()
|
||||
return
|
||||
}
|
||||
|
||||
// check if disable_images is equal to "true"
|
||||
if cookie == "true" {
|
||||
if imagesCookie == "true" {
|
||||
c.Set("disable_images", true)
|
||||
}
|
||||
|
||||
themeCookie, err := c.Cookie("theme")
|
||||
if err != nil {
|
||||
c.Next()
|
||||
return
|
||||
}
|
||||
|
||||
if themeCookie == "light" {
|
||||
c.Set("theme", "light")
|
||||
}
|
||||
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user