Documentation ¶
Index ¶
- func ContentHandler(site *Host, route Route) func(http.ResponseWriter, *http.Request)
- func InitCache() *http.Server
- func RunServer(listenAddress string, hostConfigFiles []string)
- func WaitForSignal(srv *http.Server)
- type Content
- type ContentContextValue
- type DocumentFetcher
- type FileFetcher
- type Host
- type RenderedTemplateFetcher
- type Replacement
- type Route
- type Static
- type StringFetcher
- type URIFetcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContentHandler ¶
ContentHandler uses the Source to render content
func WaitForSignal ¶
WaitForSignal blocks until SIGINT arrives.
Types ¶
type Content ¶
type Content struct { Source string `hcl:"source,optional"` // URL to fetch the main source Selector string `hcl:"select,optional"` // CSS Selector to extract content from - optional Replacements []Replacement `hcl:"replacement,block"` // May be empty CacheKey string `hcl:"cache,optional"` CacheTTL string `hcl:"ttl,optional"` Template string `hcl:"template,optional"` // Go template source -- URL JSON string `hcl:"json,optional"` // Used by templates to retrieve data -- URL // contains filtered or unexported fields }
Content is a piece of content representing a page or portion of a page
func (*Content) Fetch ¶
Fetch returns the rendered content (or from endpoint if endpoint is configured for the end point)
func (*Content) InterpolatedCacheKey ¶
InterpolatedCacheKey returns the interpolated endpoint key
type ContentContextValue ¶
ContentContextValue is passed via Context.WithValue() to the endpoint Getter Func
type DocumentFetcher ¶
DocumentFetcher are something that retrieves content
type FileFetcher ¶
type FileFetcher struct {
Path string
}
FileFetcher is a type of Fetcher that loads content from a file.
func (*FileFetcher) Fetch ¶
func (fetcher *FileFetcher) Fetch() (string, error)
Fetch returns an io.ReadCloser for the file
type Host ¶
type Host struct { Hostname string `hcl:"hostname"` Routes []Route `hcl:"route,block"` Cache *groupcache.Group MaxCache int64 `hcl:"max_cache,optional"` }
Host represents a single VHOSTed site
func ParseHostHCL ¶
ParseHostHCL will parse file content into valid Host.
func ReadHostHCL ¶
ReadHostHCL will load and parse a file containing hcl that defines a host
type RenderedTemplateFetcher ¶
type RenderedTemplateFetcher struct { Template *template.Template DataURL string // URL for the JSON source SourceFetcher DocumentFetcher RequestContext map[string]interface{} }
RenderedTemplateFetcher Parses and executes a Go template pulling data from JSONURL (if not empty)
func (*RenderedTemplateFetcher) Fetch ¶
func (fetcher *RenderedTemplateFetcher) Fetch() (string, error)
Fetch returns the rendered template TODO Break this up
type Replacement ¶
Replacement replaces content at At with Content
type Route ¶
type Route struct { Path string `hcl:",label"` // Respond to requests at this path Source *Content `hcl:"content,block"` // URL to fetch the main source StaticPath *Static `hcl:"static,block"` // URL to fetch the main source MaxRate float64 `hcl:"maxrate,optional"` AllowBurst int `hcl:"burst,optional"` BotMaxRate float64 `hcl:"botmaxrate,optional"` BotAllowBurst int `hcl:"botburst,optional"` // contains filtered or unexported fields }
Route returns content for a given path
func (*Route) ContentHandler ¶
ContentHandler uses the Source to render content
type Static ¶
type Static struct {
Directory string `hcl:"directory"`
}
Static is for defining static file routes
type StringFetcher ¶
type StringFetcher struct {
Body string
}
StringFetcher is a type of Fetcher that loads content from a string
func (*StringFetcher) Fetch ¶
func (fetcher *StringFetcher) Fetch() (string, error)
Fetch returns the string
type URIFetcher ¶
type URIFetcher struct {
URI string
}
URIFetcher is a fetcher from the network (typically http(s))
func (*URIFetcher) Fetch ¶
func (fetcher *URIFetcher) Fetch() (string, error)
Fetch returns res.Body