Documentation
¶
Index ¶
- func Resolve(ctx context.Context, comp Identifier) (string, error)
- func WithMode(ctx context.Context, mode Mode) context.Context
- func WithRequestInfo(ctx context.Context, headers http.Header, ...) context.Context
- func WithRequestInfoFromHTTP(ctx context.Context, req *http.Request) context.Context
- func WithResponseInfo(ctx context.Context, headers http.Header, statusCode int, ...) context.Context
- func WithResponseInfoFromHTTP(ctx context.Context, resp *http.Response) context.Context
- type Identifier
- func (c *Identifier) GetParameter(key string, dst any) error
- func (c *Identifier) HasParameter(key string) bool
- func (c *Identifier) MarshalSFV() ([]byte, error)
- func (c Identifier) Name() string
- func (c Identifier) Parameters() []string
- func (c *Identifier) SFV() (sfv.Item, error)
- func (c Identifier) WithParameter(key string, value any) Identifier
- type Mode
- type RequestInfo
- type ResponseInfo
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 ¶
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 ¶
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
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 Method ¶
func Method() Identifier
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) WithParameter ¶
func (c Identifier) WithParameter(key string, value any) Identifier
WithParameter creates a new component with the parameter added to the component.
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