component

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2025 License: MIT Imports: 8 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Resolve

func Resolve(ctx context.Context, comp Identifier) (string, error)

Resolve resolves the component identifier to its value. Since the resolution process requires different input for different modes/components, this function must be called after the context object has been properly set up.

func WithMode

func WithMode(ctx context.Context, mode Mode) context.Context

WithMode adds a mode to the context for later retrieval. IF unspecified, the default mode is to resolve components for HTTP requests.

func WithRequestInfo

func WithRequestInfo(ctx context.Context, headers http.Header, method, scheme, authority, path, rawQuery, targetURI string) context.Context

WithRequestInfo adds request information to the context using discrete values

func WithRequestInfoFromHTTP

func WithRequestInfoFromHTTP(ctx context.Context, req *http.Request) context.Context

WithRequestInfoFromHTTP is a convenience function that extracts request info from an http.Request and adds it to the context.

func WithResponseInfo

func WithResponseInfo(ctx context.Context, headers http.Header, statusCode int, requestInfo *RequestInfo) context.Context

WithResponseInfo adds response information to the context using discrete values

func WithResponseInfoFromHTTP

func WithResponseInfoFromHTTP(ctx context.Context, resp *http.Response) context.Context

WithResponseInfoFromHTTP is a convenience function that extracts response info from an http.Response and adds it to the context.

Types

type Identifier

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

Identifier represents an HTTP Message Signature component identifier with its name and parameters according to RFC 9421

func Authority

func Authority() Identifier

func FromItem

func FromItem(item sfv.Item) (Identifier, error)

func Method

func Method() Identifier

func New

func New(name string) Identifier

New creates a new Identifier with the given name

func Parse

func Parse(input []byte) (Identifier, error)

func QueryParam

func QueryParam() Identifier

func Status

func Status() Identifier

func TargetURI

func TargetURI() Identifier

func (*Identifier) GetParameter

func (c *Identifier) GetParameter(key string, dst any) error

GetParameter gets a parameter value

func (*Identifier) HasParameter

func (c *Identifier) HasParameter(key string) bool

HasParameter checks if the component has a specific parameter

func (*Identifier) MarshalSFV

func (c *Identifier) MarshalSFV() ([]byte, error)

String returns the RFC 9421 string representation of the component identifier

func (Identifier) Name

func (c Identifier) Name() string

func (Identifier) Parameters

func (c Identifier) Parameters() []string

func (*Identifier) SFV

func (c *Identifier) SFV() (sfv.Item, error)

func (Identifier) WithParameter

func (c Identifier) WithParameter(key string, value any) Identifier

WithParameter creates a new component with the parameter added to the component.

type Mode

type Mode int
const (
	ModeRequest Mode = iota
	ModeResponse
)

func ModeFromContext

func ModeFromContext(ctx context.Context) Mode

type RequestInfo

type RequestInfo struct {
	Headers   http.Header
	Method    string
	Scheme    string
	Authority string
	Path      string
	RawQuery  string
	TargetURI string
}

RequestInfo contains the discrete components needed for request signature resolution

func RequestInfoFromContext

func RequestInfoFromContext(ctx context.Context) (*RequestInfo, bool)

func RequestInfoFromHTTP

func RequestInfoFromHTTP(req *http.Request) *RequestInfo

Helper function to create RequestInfo from http.Request

type ResponseInfo

type ResponseInfo struct {
	Headers    http.Header
	StatusCode int
	Request    *RequestInfo // For response components that need request info
}

ResponseInfo contains the discrete components needed for response signature resolution

func ResponseInfoFromContext

func ResponseInfoFromContext(ctx context.Context) (*ResponseInfo, bool)

func ResponseInfoFromHTTP

func ResponseInfoFromHTTP(resp *http.Response) *ResponseInfo

Helper function to create ResponseInfo from http.Response

Jump to

Keyboard shortcuts

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