pages

package
v0.0.0-...-006488c Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2019 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultContentType = "text/html; charset=utf-8"

DefaultContentType is the content type that is used if none is specified.

Variables

View Source
var PushStyle = ServerPush("/css/style.css")

PushStyle pushes "/css/style.css" to the client.

Functions

func GenEtag

func GenEtag(data []byte) string

GenEtag FIXME this should be somewhere else

func NoCache

func NoCache(p *pageBase)

NoCache is an option that with completely disable caching of the page by the client.

Types

type DynamicPage

type DynamicPage struct {
	// contains filtered or unexported fields
}

DynamicPage implements a dynamic page for a website.

func NewDynamicPage

func NewDynamicPage(source DynamicPageSource, options ...PageOption) *DynamicPage

NewDynamicPage creates a new DynamicPage with the given source and options. Later options override previous ones.

func (*DynamicPage) ServeHTTP

func (page *DynamicPage) ServeHTTP(w http.ResponseWriter, req *http.Request, args interface{})

type DynamicPageSource

type DynamicPageSource interface {
	GetReader(vars interface{}) myio.ReadSeekerCloser
}

DynamicPageSource is an interface for a type that provides the ability to read the page content when given an argument.

type PageOption

type PageOption func(*pageBase)

PageOption is the type of options that is supplied to a page when created. These apply to all page types and later options given take precidence.

func ContentType

func ContentType(ct string) PageOption

ContentType is an option that sets the content type header of the page.

func Header(key, value string) PageOption

Header is an option that sets a header on the page.

func PublicCache

func PublicCache(maxAge int) PageOption

PublicCache is an option that with set the cache-control to public with the given max age.

func ServerPush

func ServerPush(path string) PageOption

ServerPush is an option that adds a server push whenever the pages is requested.

func ServerPushAs

func ServerPushAs(path, as string) PageOption

ServerPushAs is an option that adds a server push with the given "as" whenever the pages is requested.

type StaticPage

type StaticPage struct {
	// contains filtered or unexported fields
}

StaticPage implements a static page for a website.

func NewStaticPage

func NewStaticPage(source StaticPageSource, options ...PageOption) *StaticPage

NewStaticPage creates a new StaticPage with the given source and options. Later options override previous ones.

func (*StaticPage) ServeHTTP

func (page *StaticPage) ServeHTTP(w http.ResponseWriter, req *http.Request)

type StaticPageSource

type StaticPageSource interface {
	GetReader() (myio.ReadSeekerCloser, string)
}

StaticPageSource is an interface for a type that provides the ability to read the page content.

Jump to

Keyboard shortcuts

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