vprule

package
v1.0.4 Latest Latest
Warning

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

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

Documentation

Overview

Package vprule defines how to determine the validity period of signed exchanges.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Rule

type Rule interface {
	// Get returns ValidPeriod for resp. date is the value of vp.Date(),
	// where vp is the ValidPeriod.
	Get(resp *exchange.Response, date time.Time) exchange.ValidPeriod
}

Rule determines the validity period of the provided signed exchange.

var DefaultRule Rule = FixedLifetime(24 * time.Hour)

DefaultRule is the default rule used by webpackager.Packager.

func FixedLifetime

func FixedLifetime(lifetime time.Duration) Rule

FixedLifetime applies a fixed lifetime to all signed exchanges.

func PerContentType

func PerContentType(rules map[string]Rule, ruleElse Rule) Rule

PerContentType specifies a Rule per media type. rules is a map from media types to Rules; ruleElse is the Rule applied to other media types. The map keys should be all in lowercase and include no media parameters (e.g. "text/html", not "text/HTML" or "text/html; charset=utf-8").

PerContentType looks for a rule applicable to the resp's Content-Type first. If there is none, PerContentType also looks for a rule for each Webpackager-Sub-Content-Type (resp.ExtraData[exchange.SubContentType]). If there is still no rule to apply, PerContentType applies ruleElse.

Jump to

Keyboard shortcuts

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