Documentation
¶
Overview ¶
Package reportingapi is an implementation of the Report-To header described in https://www.w3.org/TR/reporting/#header.
It allows for setting reporting groups to use in conjuction with COOP and CSP.
Index ¶
Constants ¶
const DefaultMaxAge = 7 * 24 * 60 * 60
DefaultMaxAge is used as default cache duration for report groups and will make them last 7 days.
const ReportToHeaderKey = "Report-To"
ReportToHeaderKey is the HTTP header key for the Reporting API.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Endpoint ¶
type Endpoint struct { // URL defines the location of the endpoint. // The URL that the member's value represents MUST be potentially trustworthy. Non-secure endpoints will be ignored. URL string `json:"url"` // Priority defines which failover class the endpoint belongs to. Priority uint `json:"priority,omitempty"` // Weight defines load balancing for the failover class that the endpoint belongs to. Weight uint `json:"weight,omitempty"` }
Endpoint is the Go representation of the endpoints values as specified in https://www.w3.org/TR/reporting/#endpoints-member
type Group ¶
type Group struct { // Name associates a name with the set of endpoints. // This is serialized as the "group" field in the Report-To header. // If left empty, the endpoint group will be given the name "default". Name string `json:"group,omitempty"` // IncludeSubdomains enables this endpoint group for all subdomains of the current origin’s host. IncludeSubdomains bool `json:"include_subdomains,omitempty"` // MaxAge defines the endpoint group’s lifetime, as a non-negative integer number of seconds. // A value of 0 will cause the endpoint group to be removed from the user agent’s reporting cache. MaxAge uint `json:"max_age"` // Endpoints is the list of endpoints that belong to this endpoint group. Endpoints []Endpoint `json:"endpoints"` }
Group is the Go representation of the Report-To header values as specified in https://www.w3.org/TR/reporting/#header.
type Interceptor ¶
type Interceptor struct {
// contains filtered or unexported fields
}
Interceptor is the interceptor for the Report-To header.
func NewInterceptor ¶
func NewInterceptor(groups ...Group) Interceptor
NewInterceptor instantiates a new Interceptor for the given groups.
func (Interceptor) Before ¶
func (i Interceptor) Before(w safehttp.ResponseWriter, r *safehttp.IncomingRequest, cfg safehttp.InterceptorConfig) safehttp.Result
Before adds all the configured Report-To header values as separate headers.
func (Interceptor) Commit ¶
func (Interceptor) Commit(w safehttp.ResponseHeadersWriter, r *safehttp.IncomingRequest, resp safehttp.Response, _ safehttp.InterceptorConfig)
Commit is a no-op, required to satisfy the safehttp.Interceptor interface.
func (Interceptor) Match ¶
func (Interceptor) Match(safehttp.InterceptorConfig) bool
Match returns false since there are no supported configurations.