Documentation ¶
Index ¶
Constants ¶
const DefaultContentType = "text/html; charset=utf-8"
DefaultContentType is the content type that is used if none is specified.
Variables ¶
var PushStyle = ServerPush("/css/style.css")
PushStyle pushes "/css/style.css" to the client.
Functions ¶
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 ¶
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.