Documentation ¶
Overview ¶
Package prerender provides a Prerender.cloud handler implementation and a Negroni middleware.
Index ¶
- Variables
- type Options
- type Prerender
- func (p *Prerender) PreRenderHandler(rw http.ResponseWriter, or *http.Request, next http.HandlerFunc)
- func (p *Prerender) PreRenderHandlerFastHttp(ctx *fasthttp.RequestCtx) error
- func (p *Prerender) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
- func (p *Prerender) ShouldPrerender(or *http.Request) bool
- func (p *Prerender) ShouldPrerenderFastHttp(ctx *fasthttp.RequestCtx) bool
Constants ¶
This section is empty.
Variables ¶
var CrawlerUserAgents = []string{
"baiduspider",
"facebookexternalhit",
"twitterbot",
"rogerbot",
"linkedinbot",
"embedly",
"quora link preview",
"showyoubot",
"outbrain",
"pinterest",
"pinterest/0.",
"developers.google.com/+/web/snippet",
"slackbot",
"vkShare",
"W3C_Validator",
"redditbot",
"Applebot",
"WhatsApp",
"flipboard",
"tumblr",
"bitlybot",
"SkypeUriPreview",
"nuzzel",
"Discordbot",
"Google Page Speed",
}
Functions ¶
This section is empty.
Types ¶
type Options ¶
Options provides you with the ability to specify a custom Prerender.cloud URL as well as a Prerender.cloud Token to include as an X-Prerender-Token header to the upstream server.
func NewOptions ¶
func NewOptions() *Options
NewOptions generates a default Options struct pointing to the Prerender.cloud service, obtaining a Token from the environment variable PRERENDER_TOKEN.
func (*Options) NewPrerender ¶
NewPrerender generates a new Prerender instance.
type Prerender ¶
type Prerender struct {
Options *Options
}
Prerender exposes methods to validate and serve content from a Prerender.cloud upstream server.
func (*Prerender) PreRenderHandler ¶
func (p *Prerender) PreRenderHandler(rw http.ResponseWriter, or *http.Request, next http.HandlerFunc)
PreRenderHandler is a net/http compatible handler that proxies a request to the configured Prerender.cloud URL. All upstream requests are made with an Accept-Encoding=gzip header. Responses are provided either uncompressed or gzip compressed based on the downstream requests Accept-Encoding header
func (*Prerender) PreRenderHandlerFastHttp ¶
func (p *Prerender) PreRenderHandlerFastHttp(ctx *fasthttp.RequestCtx) error
func (*Prerender) ServeHTTP ¶
func (p *Prerender) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
ServeHTTP allows Prerender to act as a Negroni middleware.
func (*Prerender) ShouldPrerender ¶
ShouldPrerender analyzes the request to determine whether it should be routed to a Prerender.cloud upstream server.
func (*Prerender) ShouldPrerenderFastHttp ¶
func (p *Prerender) ShouldPrerenderFastHttp(ctx *fasthttp.RequestCtx) bool