mirror of
https://github.com/httpjamesm/AnonymousOverflow.git
synced 2025-04-25 08:16:09 +00:00
24 lines
394 B
Go
24 lines
394 B
Go
|
package middleware
|
||
|
|
||
|
import "github.com/gin-gonic/gin"
|
||
|
|
||
|
func OptionsMiddleware() gin.HandlerFunc {
|
||
|
return func(c *gin.Context) {
|
||
|
c.Set("disable_images", false)
|
||
|
|
||
|
// get cookie
|
||
|
cookie, err := c.Cookie("disable_images")
|
||
|
if err != nil {
|
||
|
c.Next()
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// check if disable_images is equal to "true"
|
||
|
if cookie == "true" {
|
||
|
c.Set("disable_images", true)
|
||
|
}
|
||
|
|
||
|
c.Next()
|
||
|
}
|
||
|
}
|