package middleware import ( "github.com/gin-gonic/gin" ) // CCPAContextKey is the key used to store "Do Not Sell" preference in context const CCPAContextKey = "do_not_sell" // CCPA middleware reads the Sec-GPC (Global Privacy Control) header. // When Sec-GPC: 1 is present, it sets do_not_sell=true in context and adds GPC: 1 to the response. // This honors the CCPA "Do Not Sell" signal per Global Privacy Control specification. func CCPA() gin.HandlerFunc { return func(c *gin.Context) { if c.GetHeader("Sec-GPC") == "1" { c.Set(CCPAContextKey, true) c.Header("GPC", "1") } c.Next() } }