request

package
v0.0.0-...-57974ef Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: Apache-2.0 Imports: 3 Imported by: 19

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Request_HtmlFormat_name = map[int32]string{
	0: "UNKNOWN_CODE",
	1: "AMP",
	2: "AMP4ADS",
	3: "AMP4EMAIL",
	4: "EXPERIMENTAL",
}
View Source
var Request_HtmlFormat_value = map[string]int32{
	"UNKNOWN_CODE": 0,
	"AMP":          1,
	"AMP4ADS":      2,
	"AMP4EMAIL":    3,
	"EXPERIMENTAL": 4,
}
View Source
var Request_TransformersConfig_name = map[int32]string{
	0: "DEFAULT",
	1: "NONE",
	2: "VALIDATION",
	3: "CUSTOM",
}
View Source
var Request_TransformersConfig_value = map[string]int32{
	"DEFAULT":    0,
	"NONE":       1,
	"VALIDATION": 2,
	"CUSTOM":     3,
}

Functions

This section is empty.

Types

type Metadata

type Metadata struct {
	// Absolute URLs of resources that should be preloaded when the AMP is
	// prefetched. In a signed exchange (SXG) context, these would be included as
	// `Link: rel=preload` headers, as these are used by the browser during SXG
	// prefetch:
	// https://github.com/WICG/webpackage/blob/master/explainer.md#prefetching-stops-here
	Preloads []*Metadata_Preload `protobuf:"bytes,1,rep,name=preloads,proto3" json:"preloads,omitempty"`
	// Recommended validity duration (`expires - date`), in seconds, of the SXG,
	// based on the content being signed. In particular, JS is given a shorter
	// lifetime to reduce risk of issues due to downgrades:
	// https://wicg.github.io/webpackage/draft-yasskin-http-origin-signed-responses.html#seccons-downgrades.
	MaxAgeSecs           int32    `protobuf:"varint,2,opt,name=max_age_secs,json=maxAgeSecs,proto3" json:"max_age_secs,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

A Metadata is part of the transformers' response, and includes additional information either not present in or not easily accessible from the HTML. It should remain relatively small, as it undergoes a serialization/deserialization round-trip when the Go library is called from C.

func (*Metadata) Descriptor

func (*Metadata) Descriptor() ([]byte, []int)

func (*Metadata) GetMaxAgeSecs

func (m *Metadata) GetMaxAgeSecs() int32

func (*Metadata) GetPreloads

func (m *Metadata) GetPreloads() []*Metadata_Preload

func (*Metadata) ProtoMessage

func (*Metadata) ProtoMessage()

func (*Metadata) Reset

func (m *Metadata) Reset()

func (*Metadata) String

func (m *Metadata) String() string

func (*Metadata) XXX_DiscardUnknown

func (m *Metadata) XXX_DiscardUnknown()

func (*Metadata) XXX_Marshal

func (m *Metadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Metadata) XXX_Merge

func (m *Metadata) XXX_Merge(src proto.Message)

func (*Metadata) XXX_Size

func (m *Metadata) XXX_Size() int

func (*Metadata) XXX_Unmarshal

func (m *Metadata) XXX_Unmarshal(b []byte) error

type Metadata_Preload

type Metadata_Preload struct {
	// The URL of the resource to preload. Will be an absolute URL on the domain
	// of the target AMP cache.
	Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"`
	// The `as` attribute of the preload, as specified in
	// https://w3c.github.io/preload/#as-attribute and
	// https://html.spec.whatwg.org/multipage/semantics.html#attr-link-as. The
	// full list of potential values is specified in
	// https://fetch.spec.whatwg.org/#concept-request-destination, though for
	// the time being only "script", "style", and "image" are allowed.
	As string `protobuf:"bytes,2,opt,name=as,proto3" json:"as,omitempty"`
	// The media attribute for image preload link. This attribute is useful
	// only for image links. Deprecated, instead use the `attributes` field.
	Media string `protobuf:"bytes,3,opt,name=media,proto3" json:"media,omitempty"` // Deprecated: Do not use.
	// Optional remaining attributes. This does not include the `href` or `as`
	// attributes.
	Attributes []*Metadata_Preload_Attribute `protobuf:"bytes,4,rep,name=attributes,proto3" json:"attributes,omitempty"`
	// If true, this is a modulepreload instead of a preload.
	Module               bool     `protobuf:"varint,5,opt,name=module,proto3" json:"module,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Metadata_Preload) Descriptor

func (*Metadata_Preload) Descriptor() ([]byte, []int)

func (*Metadata_Preload) GetAs

func (m *Metadata_Preload) GetAs() string

func (*Metadata_Preload) GetAttributes

func (m *Metadata_Preload) GetAttributes() []*Metadata_Preload_Attribute

func (*Metadata_Preload) GetMedia deprecated

func (m *Metadata_Preload) GetMedia() string

Deprecated: Do not use.

func (*Metadata_Preload) GetModule

func (m *Metadata_Preload) GetModule() bool

func (*Metadata_Preload) GetUrl

func (m *Metadata_Preload) GetUrl() string

func (*Metadata_Preload) ProtoMessage

func (*Metadata_Preload) ProtoMessage()

func (*Metadata_Preload) Reset

func (m *Metadata_Preload) Reset()

func (*Metadata_Preload) String

func (m *Metadata_Preload) String() string

func (*Metadata_Preload) XXX_DiscardUnknown

func (m *Metadata_Preload) XXX_DiscardUnknown()

func (*Metadata_Preload) XXX_Marshal

func (m *Metadata_Preload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Metadata_Preload) XXX_Merge

func (m *Metadata_Preload) XXX_Merge(src proto.Message)

func (*Metadata_Preload) XXX_Size

func (m *Metadata_Preload) XXX_Size() int

func (*Metadata_Preload) XXX_Unmarshal

func (m *Metadata_Preload) XXX_Unmarshal(b []byte) error

type Metadata_Preload_Attribute

type Metadata_Preload_Attribute struct {
	Key                  string   `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	Val                  string   `protobuf:"bytes,2,opt,name=val,proto3" json:"val,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Metadata_Preload_Attribute) Descriptor

func (*Metadata_Preload_Attribute) Descriptor() ([]byte, []int)

func (*Metadata_Preload_Attribute) GetKey

func (m *Metadata_Preload_Attribute) GetKey() string

func (*Metadata_Preload_Attribute) GetVal

func (m *Metadata_Preload_Attribute) GetVal() string

func (*Metadata_Preload_Attribute) ProtoMessage

func (*Metadata_Preload_Attribute) ProtoMessage()

func (*Metadata_Preload_Attribute) Reset

func (m *Metadata_Preload_Attribute) Reset()

func (*Metadata_Preload_Attribute) String

func (m *Metadata_Preload_Attribute) String() string

func (*Metadata_Preload_Attribute) XXX_DiscardUnknown

func (m *Metadata_Preload_Attribute) XXX_DiscardUnknown()

func (*Metadata_Preload_Attribute) XXX_Marshal

func (m *Metadata_Preload_Attribute) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Metadata_Preload_Attribute) XXX_Merge

func (m *Metadata_Preload_Attribute) XXX_Merge(src proto.Message)

func (*Metadata_Preload_Attribute) XXX_Size

func (m *Metadata_Preload_Attribute) XXX_Size() int

func (*Metadata_Preload_Attribute) XXX_Unmarshal

func (m *Metadata_Preload_Attribute) XXX_Unmarshal(b []byte) error

type Request

type Request struct {
	// The AMP HTML document to transform.
	Html string `protobuf:"bytes,1,opt,name=html,proto3" json:"html,omitempty"`
	// The public URL of the document, i.e. the location that should appear in
	// the browser URL bar.
	DocumentUrl string `protobuf:"bytes,2,opt,name=document_url,json=documentUrl,proto3" json:"document_url,omitempty"`
	// The AMP runtime version.
	Rtv string `protobuf:"bytes,4,opt,name=rtv,proto3" json:"rtv,omitempty"`
	// The CSS contents to inline into the transformed HTML
	Css string `protobuf:"bytes,5,opt,name=css,proto3" json:"css,omitempty"`
	// Transformations are only run if the HTML tag contains the attribute
	// specifying one of the provided formats. If allowed_formats is empty, then
	// all non-experimental AMP formats are allowed.
	AllowedFormats []Request_HtmlFormat       `` /* 149-byte string literal not displayed */
	Config         Request_TransformersConfig `protobuf:"varint,6,opt,name=config,proto3,enum=amp.transform.Request_TransformersConfig" json:"config,omitempty"`
	// If config == CUSTOM, this is the list of custom transformers to execute,
	// in the order provided here. Otherwise, this is ignored.
	Transformers []string `protobuf:"bytes,3,rep,name=transformers,proto3" json:"transformers,omitempty"`
	// The version of the transforms to perform (optional). If specified, it must
	// be a supported version.
	Version              int64    `protobuf:"varint,8,opt,name=version,proto3" json:"version,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

A Request encapsulates input and contextual parameters for use by the transformers.

func (*Request) Descriptor

func (*Request) Descriptor() ([]byte, []int)

func (*Request) GetAllowedFormats

func (m *Request) GetAllowedFormats() []Request_HtmlFormat

func (*Request) GetConfig

func (m *Request) GetConfig() Request_TransformersConfig

func (*Request) GetCss

func (m *Request) GetCss() string

func (*Request) GetDocumentUrl

func (m *Request) GetDocumentUrl() string

func (*Request) GetHtml

func (m *Request) GetHtml() string

func (*Request) GetRtv

func (m *Request) GetRtv() string

func (*Request) GetTransformers

func (m *Request) GetTransformers() []string

func (*Request) GetVersion

func (m *Request) GetVersion() int64

func (*Request) ProtoMessage

func (*Request) ProtoMessage()

func (*Request) Reset

func (m *Request) Reset()

func (*Request) String

func (m *Request) String() string

func (*Request) XXX_DiscardUnknown

func (m *Request) XXX_DiscardUnknown()

func (*Request) XXX_Marshal

func (m *Request) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Request) XXX_Merge

func (m *Request) XXX_Merge(src proto.Message)

func (*Request) XXX_Size

func (m *Request) XXX_Size() int

func (*Request) XXX_Unmarshal

func (m *Request) XXX_Unmarshal(b []byte) error

type Request_HtmlFormat

type Request_HtmlFormat int32

This should be kept in sync with HtmlFormat.Code in github.com/ampproject/amphtml/validator/validator.proto. Deprecated fields, do not reuse: reserved 5;

const (
	Request_UNKNOWN_CODE Request_HtmlFormat = 0
	Request_AMP          Request_HtmlFormat = 1
	Request_AMP4ADS      Request_HtmlFormat = 2
	Request_AMP4EMAIL    Request_HtmlFormat = 3
	Request_EXPERIMENTAL Request_HtmlFormat = 4
)

func (Request_HtmlFormat) EnumDescriptor

func (Request_HtmlFormat) EnumDescriptor() ([]byte, []int)

func (Request_HtmlFormat) String

func (x Request_HtmlFormat) String() string

type Request_TransformersConfig

type Request_TransformersConfig int32
const (
	// Execute the default list of transformers. For packager production
	// environments, this should be the config used.
	Request_DEFAULT Request_TransformersConfig = 0
	// Execute none, and simply parse and re-emit. Some normalization will be
	// performed regardless, including, but not limited to:
	// - HTML normalization (e.g. closing all non-void tags).
	// - removal of all comments
	// - lowercase-ing of attribute keys
	// - lexical sort of attribute keys
	// - text is escaped
	//
	// WARNING. THIS IS FOR TESTING PURPOSES ONLY.
	// Use of this setting in a packager production environment could produce
	// invalid transformed AMP when ingested by AMP caches.
	Request_NONE Request_TransformersConfig = 1
	// Execute the minimum needed for verification/validation.
	//
	// WARNING. FOR AMP CACHE USE ONLY.
	// Use of this setting in a packager production environment could produce
	// invalid transformed AMP when ingested by AMP caches.
	Request_VALIDATION Request_TransformersConfig = 2
	// Execute a custom set of transformers.
	//
	// WARNING. THIS IS FOR TESTING PURPOSES ONLY.
	// Use of this setting in a packager production environment could produce
	// invalid transformed AMP when ingested by AMP caches.
	Request_CUSTOM Request_TransformersConfig = 3
)

func (Request_TransformersConfig) EnumDescriptor

func (Request_TransformersConfig) EnumDescriptor() ([]byte, []int)

func (Request_TransformersConfig) String

type VersionRange

type VersionRange struct {
	Min                  int64    `protobuf:"varint,1,opt,name=min,proto3" json:"min,omitempty"`
	Max                  int64    `protobuf:"varint,2,opt,name=max,proto3" json:"max,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

An inclusive range of version numbers.

func (*VersionRange) Descriptor

func (*VersionRange) Descriptor() ([]byte, []int)

func (*VersionRange) GetMax

func (m *VersionRange) GetMax() int64

func (*VersionRange) GetMin

func (m *VersionRange) GetMin() int64

func (*VersionRange) ProtoMessage

func (*VersionRange) ProtoMessage()

func (*VersionRange) Reset

func (m *VersionRange) Reset()

func (*VersionRange) String

func (m *VersionRange) String() string

func (*VersionRange) XXX_DiscardUnknown

func (m *VersionRange) XXX_DiscardUnknown()

func (*VersionRange) XXX_Marshal

func (m *VersionRange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*VersionRange) XXX_Merge

func (m *VersionRange) XXX_Merge(src proto.Message)

func (*VersionRange) XXX_Size

func (m *VersionRange) XXX_Size() int

func (*VersionRange) XXX_Unmarshal

func (m *VersionRange) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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