crewjam / csp

go library for generating Content-Security-Policy headers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

csp

Build Status Documentation

Package csp provides structures to add Content-Security-Policy headers to HTTP responses.

import (
	"net/http"

	"github.com/crewjam/csp"
)

func HeaderExample(w http.ResponseWriter, r *http.Request) {
	r.Header.Add("Content-Security-Policy", csp.Header{
		DefaultSrc: []string{"'self'", "static.example.com"},
	}.String())
}

About

go library for generating Content-Security-Policy headers

License:BSD 2-Clause "Simplified" License


Languages

Language:Go 100.0%