Documentation ¶
Overview ¶
Package validity handles the validity data of signed exchanges. It only defines validity URLs at the moment though.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type URLRule ¶
type URLRule interface { // Apply returns the validity URL of a resource. physurl is the physical // URL of the resource; resp is the HTTP response; vp is the period the // signed exchange will be valid for. The physical URL is typically equal // to the request URL but different in some cases; see package urlrewrite // for more details. // // Note implementations can retrieve the request URL via resp.Request.URL. Apply(physurl *url.URL, resp *exchange.Response, vp exchange.ValidPeriod) (*url.URL, error) }
URLRule decides the validity URL of a resource.
var DefaultURLRule URLRule = AppendExtDotLastModified(".validity")
DefaultURLRule is the default rule used by webpackager.Packager.
func AppendExtDotExchangeDate ¶
AppendExtDotExchangeDate is like AppendExtDotLastModified but always uses vp.Date instead of the last modified time.
func AppendExtDotLastModified ¶
AppendExtDotLastModified generates the validity URL by appending ext and the resource's last modified time. For example:
https://example.com/index.html
would receive a validity URL that looks like:
https://example.com/index.html.validity.1561984496
ext usually starts with a dot ("."). AppendExtDotExchangeDate does not insert it automatically. ext is thus ".validity" rather than "validity" in the example above.
The last modified time is taken from the Last-Modified header field in the HTTP response and represented in UNIX time. If the Last-Modified is missing or unparsable, AppendExtDotLastModified uses the date value of the signed exchange signature (vp.Date).
The AppendExtDotLastModified rule does not support physurl that looks like a directory (e.g. has Path ending with a slash). Apply returns an error for such physurl. Note you can use urlrewrite.IndexRule to ensure physurl to always have a filename.
The AppendExtDotLastModified rule ignores Query and Fragment in physurl. The validity URLs will always have empty Query and Fragment.
func FixedURL ¶
FixedURL uses url as the validity URL for all resources. It is useful, for example, if you plan to provide empty validity data (consisting of a single byte 0xa0) for all signed exchanges and serve it on a single URL.
url can be relative, in which case the validity URL is resolved relative from the physical URL.