websession

package
v0.0.0-...-fd1ce1a Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ContextHeaderFilter is a header filter for WebSession.Context.additionalHeaders
	ContextHeaderFilter = util.Must(ParseHeaderWhitelist(websession.Context_headerWhitelist))

	// ResponseHeaderFilter is a header filter for WebSession.Response.additionalHeaders
	ResponseHeaderFilter = util.Must(ParseHeaderWhitelist(websession.Response_headerWhitelist))
)

Functions

This section is empty.

Types

type Handler

type Handler struct {
	Session websession.WebSession
}

A Handler implements http.Handler on top of a WebSession. NOTE: this is work in progress; some of the methods documented in web-session.capnp are not implemented and will return HTTP 405 "Method Not Allowed" responses.

func (Handler) ServeHTTP

func (h Handler) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP implements http.Handler.ServeHTTP

type HeaderFilter

type HeaderFilter struct {
	// contains filtered or unexported fields
}

A HeaderFilter filters headers based on an allow list.

func NewHeaderFilter

func NewHeaderFilter() HeaderFilter

NewHeaderFilter a new empty header filter (i.e. one that drops all headers).

func ParseHeaderWhitelist

func ParseHeaderWhitelist(l capnp.TextList) (HeaderFilter, error)

ParseHeaderWhiteList parses the `headerWhitelist` fields defined in web-session.capnp, and returns a corresponding HeaderFilter.

func (*HeaderFilter) AddAllow

func (hf *HeaderFilter) AddAllow(rule string)

AddAllow adds an allow rule to the filter. If the rule ends in '*' it is a prefix, otherwise it is an exact value.

func (HeaderFilter) Allows

func (hf HeaderFilter) Allows(name string) bool

Allows returns true iff the header filter allows the named header.

func (HeaderFilter) Copy

func (hf HeaderFilter) Copy(dst, src http.Header)

Copy copies all headers allowed by the filter

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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