amper

package module
v4.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2018 License: CC0-1.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCDNDomain = "cdn.ampproject.org"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// Host is the hostname of the backend to use.
	Host string
	// Front is the hostname sent in TLS SNI.
	Front string
	// Path is the prefix path for making requests.
	Path string
	// Transport is the http.RoundTripper to use to perform requests.
	// If Transport is nil then http.DefaultTransport is used.
	Transport http.RoundTripper
	// CDNDomain is the domain suffix of the AMP CDN.
	// If empty, DefaultCDNDomain is used.
	CDNDomain string
	// Scheme specifies the URL scheme for accessing AMP CDN.
	// Scheme is either "https" or "http".
	// If empty, Scheme defaults to "https".
	Scheme string
	// Query specifies query parameters to set for the URL.
	// Defaults to "amp_js_v=0.1".
	Query url.Values
}

Client desribes a client state.

func (*Client) RoundTrip

func (c *Client) RoundTrip(r io.Reader) (io.ReadCloser, error)

RoundTrip writes data from reader r to the server and returns reply from the server.

type Handler

type Handler interface {
	Handle(w io.Writer, r io.Reader) error
}

func HandlerFunc

func HandlerFunc(hf func(w io.Writer, r io.Reader) error) Handler

Handler wraps a handle function hf into Handler.

type Server

type Server struct {
	// Handler to handle requests
	Handler Handler
	// Allow non-AMP remotes
	AllowAllRemotes bool
	// UseOldBoilerplate makes AMP encoder use
	// deprecated AMP boilerplate. As it's much shorter
	// than the new one, one may benefit from using it
	// to save some bandwidth.
	// Note that it may stop working in future.
	UseOldAMPBoilerplate bool
}

func (*Server) ServeHTTP

func (ah *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis
codec
amp
get
examples

Jump to

Keyboard shortcuts

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