conditional

package
v1.14.2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Params

type Params struct {
	IfMatch           []string  `header:"If-Match" doc:"Succeeds if the server's resource matches one of the passed values."`
	IfNoneMatch       []string  `` /* 169-byte string literal not displayed */
	IfModifiedSince   time.Time `header:"If-Modified-Since" doc:"Succeeds if the server's resource date is more recent than the passed date."`
	IfUnmodifiedSince time.Time `header:"If-Unmodified-Since" doc:"Succeeds if the server's resource date is older or the same as the passed date."`
	// contains filtered or unexported fields
}

Params allow clients to send ETags or times to make a read or write conditional based on the state of the resource on the server, e.g. when it was last modified. This is useful for determining when a cache should be updated or to prevent multiple writers from overwriting each other's changes.

func (*Params) HasConditionalParams

func (p *Params) HasConditionalParams() bool

HasConditionalParams returns true if any conditional request headers have been set on the incoming request.

func (*Params) PreconditionFailed

func (p *Params) PreconditionFailed(ctx huma.Context, etag string, modified time.Time) bool

PreconditionFailed returns false if no conditional headers are present, or if the values passed fail based on the conditional read/write rules. See also: https://developer.mozilla.org/en-US/docs/Web/HTTP/Conditional_requests. This method assumes there is some fast/efficient way to get a resource's current ETag and/or last-modified time before it is run.

func (*Params) Resolve

func (p *Params) Resolve(ctx huma.Context, r *http.Request)

Jump to

Keyboard shortcuts

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