mirror of
https://github.com/httpjamesm/AnonymousOverflow.git
synced 2025-04-25 00:06:12 +00:00
23 lines
394 B
Go
23 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()
|
|
}
|
|
}
|