Documentation
¶
Overview ¶
Package csp provides an HTTP handler for setting Content-Security-Policy headers and receiving CSP violation reports.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Policy *Policy // if non-nil, configures the Content-Security-Policy header PolicyReportOnly *Policy // if non-nil, configures the Content-Security-Policy-Report-Only header }
Config configures the Content Security Policy headers sent by Handler.
type Handler ¶
type Handler struct { // ReportLog is the logger that CSP violation reports are sent // to. If nil, the default logger (from package log) is used. ReportLog *log.Logger // contains filtered or unexported fields }
Handler sets Content-Security-Policy{,-Report-Only} headers and logs CSP reports to stderr.
func NewHandler ¶
NewHandler creates a new handler that adds the configured Content Security Policy (CSP) headers to HTTP responses. If cfg is invalid, NewHandler returns an error.
func (*Handler) ServeHTTP ¶
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
ServeHTTP implements http.Handler.
Click to show internal directories.
Click to hide internal directories.