Browse Source

Add Google FLoC opt-out header on web page requests. Closes #939

pull/941/head
Gabe Kangas 4 years ago
parent
commit
8287484cc6
  1. 3
      controllers/index.go
  2. 8
      router/middleware/disableFloc.go

3
controllers/index.go

@ -64,6 +64,9 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) { @@ -64,6 +64,9 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) {
// Set a cache control max-age header
middleware.SetCachingHeaders(w, r)
// Opt-out of Google FLoC
middleware.DisableFloc(w)
http.ServeFile(w, r, path.Join(config.WebRoot, r.URL.Path))
}

8
router/middleware/disableFloc.go

@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
package middleware
import "net/http"
// DisableFloc will tell Google to not use this response in their FLoC tracking.
func DisableFloc(w http.ResponseWriter) {
w.Header().Set("Permissions-Policy", "interest-cohort=()")
}
Loading…
Cancel
Save