resource

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package resource defines representations of resources to generate signed exchanges for.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Resource

type Resource struct {
	// RequestURL is the location to request this resource.
	RequestURL *url.URL

	// RedirectURL is non-nil when RequestURL gets redirected, and the value
	// represents the location after the redirect.
	//
	// All other fields, except RequestURL, should be unset when RedirectURL
	// has a non-nil value.
	RedirectURL *url.URL

	// PhysicalURL is the physical location of this resource. It is usually
	// identical to RequestURL, but can be different when the web server has
	// URL rewriting mechanism (e.g. to serve "index.html").
	//
	// See also: Package urlrewrite.
	PhysicalURL *url.URL

	// ValidityURL represents the location of the validity data.
	ValidityURL *url.URL

	// Exchange represents a signed exchange generated for this resource.
	//
	// Exchange should be set through the SetExchange method to keep in sync
	// with the Integrity field.
	Exchange *signedexchange.Exchange

	// Integrity represents the integirty of HTTP response headers for this
	// resource. Technically, it is the hash of the CBOR representation of
	// the response headers in the signed exchange, prefixed by the algorithm
	// and base64-encoded ("sha256-wZp5f6H9...").
	//
	// Integrity is set by the SetExchange method.
	Integrity string
}

Resource represents a resource for which a signed exchange is generated.

func NewResource

func NewResource(url *url.URL) *Resource

NewResource creates and initializes a new Resource for url.

func (*Resource) AllowedAltSXGHeader

func (r *Resource) AllowedAltSXGHeader() string

AllowedAltSXGHeader returns the value of a Link HTTP header to allow the resource to be distributed from different domains (rel="allowed-alt-sxg").

func (*Resource) SetExchange

func (r *Resource) SetExchange(e *signedexchange.Exchange) error

SetExchange populates r.Exchange with the provided signed exchange e and updates r.Integrity accordingly. It returns a non-nil error when it fails to compute the new integrity value, in which case r is not mutated.

func (*Resource) String

func (r *Resource) String() string

String returns a string representing the Resource.

Directories

Path Synopsis
Package cache defines the ResourceCache interface and provides the most basic implementation.
Package cache defines the ResourceCache interface and provides the most basic implementation.
filewrite
Package filewrite provides ResourceCache that also saves signed exchanges to files on the Store operations to the cache.
Package filewrite provides ResourceCache that also saves signed exchanges to files on the Store operations to the cache.
Package httplink defines a representation of Web Linkings.
Package httplink defines a representation of Web Linkings.
Package preload defines representations of preload links.
Package preload defines representations of preload links.
preloadtest
Package preloadtest provides utilities for preload link testing.
Package preloadtest provides utilities for preload link testing.

Jump to

Keyboard shortcuts

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