csp

package
v0.0.0-...-8b1f4d0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package csp contains a representation of Content-Security-Policy header directives.

Index

Constants

View Source
const (
	BaseURI        = "base-uri"
	ConnectSource  = "connect-src"
	DefaultSource  = "default-src"
	FormAction     = "form-action"
	FrameAncestors = "frame-ancestors"
	ImageSource    = "img-src"
	ScriptSource   = "script-src"
	StyleSource    = "style-src"
	WorkerSource   = "worker-src"
)

Directive names.

View Source
const (
	KeywordBlob         = "blob:"
	KeywordData         = "data:"
	KeywordNone         = "'none'"
	KeywordSelf         = "'self'"
	KeywordUnsafeHashes = "'unsafe-hashes'"
)

Keywords available for directives.

View Source
const HeaderKey = "Content-Security-Policy"

HeaderKey is the canonical header key.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContentSecurityPolicy

type ContentSecurityPolicy map[string][]string

ContentSecurityPolicy represents Content-Security-Policy header directives

func (ContentSecurityPolicy) Encoded

func (policy ContentSecurityPolicy) Encoded() string

Encoded returns the encoded form of the header.

func (ContentSecurityPolicy) Middleware

func (policy ContentSecurityPolicy) Middleware(next http.Handler) http.Handler

Middleware sets the Content-Security-Policy header in the handler's responses.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL