Documentation
¶
Index ¶
- Constants
- Variables
- func AddCacheControl(context *fasthttp.RequestCtx, value string)
- func AddContentEncoding(context *fasthttp.RequestCtx, value string)
- func AddETag(context *fasthttp.RequestCtx, eTag string)
- func CallJavaScript(runtime *goja.Runtime, function JavaScriptFunc, arguments ...interface{}) interface{}
- func CreateFacet(config ard.StringMap, context *js.Context) (interface{}, error)
- func CreateResource(config ard.StringMap, context *js.Context) (interface{}, error)
- func CreateRoute(config ard.StringMap, context *js.Context) (interface{}, error)
- func CreateRouter(config ard.StringMap, context *js.Context) (interface{}, error)
- func CreateServer(config ard.StringMap, context *js.Context) (interface{}, error)
- func CreateStatic(config ard.StringMap, context *js.Context) (interface{}, error)
- func GetContentEncoding(context *fasthttp.RequestCtx) string
- func GetETag(context *fasthttp.RequestCtx) string
- func GetEncodingType(name string) platform.EncodingType
- func GetLastModified(context *fasthttp.RequestCtx) time.Time
- func GetQuery(context *fasthttp.RequestCtx) map[string][]string
- func Handled(context *Context) bool
- func IfNoneMatch(context *fasthttp.RequestCtx, eTag string) bool
- func NotFound(context *fasthttp.RequestCtx) bool
- func ParseAccept(context *Context) []string
- func SetBestEncodeWriter(context *Context)
- type CaptureFunc
- type CaptureWriter
- type Context
- func (self *Context) Copy() *Context
- func (self *Context) DeleteCachedRepresentation()
- func (self *Context) DescribeCachedRepresentation(cached *platform.CachedRepresentation) bool
- func (self *Context) ETag() string
- func (self *Context) Embed(function goja.FunctionCall, runtime *goja.Runtime) goja.Value
- func (self *Context) EndCapture() error
- func (self *Context) EndRender() error
- func (self *Context) EndSignature() error
- func (self *Context) Error(err error)
- func (self *Context) GetCachedRepresentationBody(cached *platform.CachedRepresentation) ([]byte, bool)
- func (self *Context) LoadCachedRepresentation() (platform.CacheKey, *platform.CachedRepresentation, bool)
- func (self *Context) NewCacheKey() platform.CacheKey
- func (self *Context) NewCachedRepresentation(withBody bool) *platform.CachedRepresentation
- func (self *Context) NewCachedRepresentationFromBody(encoding platform.EncodingType, body []byte) *platform.CachedRepresentation
- func (self *Context) PresentCachedRepresentation(cached *platform.CachedRepresentation, withBody bool) bool
- func (self *Context) Rename(name string) *Context
- func (self *Context) Request() string
- func (self *Context) StartCapture(name string)
- func (self *Context) StartRender(renderer string, resolve js.ResolveFunc) error
- func (self *Context) StartSignature()
- func (self *Context) StoreCachedRepresentation(withBody bool)
- func (self *Context) StoreCachedRepresentationFromBody(encoding platform.EncodingType, body []byte)
- func (self *Context) Write(b []byte) (int, error)
- func (self *Context) WriteCachedRepresentation(cached *platform.CachedRepresentation) (bool, int, error)
- func (self *Context) WriteString(s string) (int, error)
- type EncodeWriter
- type Facet
- type HandleFunc
- type Handler
- type HashWriter
- type JavaScriptFunc
- type Logger
- type PathTemplate
- type PathTemplates
- type RenderWriter
- type Representation
- type Representations
- type RepresentionFunc
- type Resource
- type Route
- type Router
- type Server
- type Static
- type WrappingWriter
Constants ¶
View Source
const ( PATH_HEADER = "X-Prudence-Path" CACHED_HEADER = "X-Prudence-Cached" )
View Source
const ( PATH_VARIABLE = "__path" PATH_VARIABLE_RE = `(?P<` + PATH_VARIABLE + `>.*)` )
Variables ¶
View Source
var DefaultNotFound defaultNotFound
View Source
var PathTemplateAll = &PathTemplate{"", nil}
Functions ¶
func AddCacheControl ¶
func AddCacheControl(context *fasthttp.RequestCtx, value string)
func AddContentEncoding ¶
func AddContentEncoding(context *fasthttp.RequestCtx, value string)
func AddETag ¶
func AddETag(context *fasthttp.RequestCtx, eTag string)
func CallJavaScript ¶
func CallJavaScript(runtime *goja.Runtime, function JavaScriptFunc, arguments ...interface{}) interface{}
func CreateFacet ¶
CreateFunc signature
func CreateResource ¶
CreateFunc signature
func CreateRoute ¶
CreateFunc signature
func CreateRouter ¶
CreateFunc signature
func CreateServer ¶
CreateFunc signature
func CreateStatic ¶
CreateFunc signature
func GetContentEncoding ¶
func GetContentEncoding(context *fasthttp.RequestCtx) string
func GetETag ¶
func GetETag(context *fasthttp.RequestCtx) string
func GetEncodingType ¶
func GetEncodingType(name string) platform.EncodingType
func GetLastModified ¶
func GetLastModified(context *fasthttp.RequestCtx) time.Time
func IfNoneMatch ¶
func IfNoneMatch(context *fasthttp.RequestCtx, eTag string) bool
func NotFound ¶
func NotFound(context *fasthttp.RequestCtx) bool
func ParseAccept ¶
func SetBestEncodeWriter ¶
func SetBestEncodeWriter(context *Context)
Types ¶
type CaptureFunc ¶
type CaptureWriter ¶
type CaptureWriter struct {
// contains filtered or unexported fields
}
func NewCaptureWriter ¶
func NewCaptureWriter(writer io.Writer, name string, capture CaptureFunc) *CaptureWriter
func (*CaptureWriter) GetWrappedWriter ¶
func (self *CaptureWriter) GetWrappedWriter() io.Writer
WrappingWriter interface
type Context ¶
type Context struct {
Context *fasthttp.RequestCtx
Name string
Log logging.Logger
Debug bool
Variables ard.StringMap
Path string
Method string
Query map[string][]string
ContentType string
CharSet string
Language string
Done bool
Created bool
Async bool
CacheDuration float64 // seconds
CacheKey string
CacheGroups []string
Signature string
WeakSignature bool
Timestamp time.Time
// contains filtered or unexported fields
}
func NewContext ¶
func NewContext(context *fasthttp.RequestCtx) *Context
func (*Context) DeleteCachedRepresentation ¶
func (self *Context) DeleteCachedRepresentation()
func (*Context) DescribeCachedRepresentation ¶
func (self *Context) DescribeCachedRepresentation(cached *platform.CachedRepresentation) bool
func (*Context) EndCapture ¶
func (*Context) EndSignature ¶
func (*Context) GetCachedRepresentationBody ¶
func (self *Context) GetCachedRepresentationBody(cached *platform.CachedRepresentation) ([]byte, bool)
func (*Context) LoadCachedRepresentation ¶
func (*Context) NewCacheKey ¶
func (*Context) NewCachedRepresentation ¶
func (self *Context) NewCachedRepresentation(withBody bool) *platform.CachedRepresentation
func (*Context) NewCachedRepresentationFromBody ¶
func (self *Context) NewCachedRepresentationFromBody(encoding platform.EncodingType, body []byte) *platform.CachedRepresentation
func (*Context) PresentCachedRepresentation ¶
func (self *Context) PresentCachedRepresentation(cached *platform.CachedRepresentation, withBody bool) bool
func (*Context) StartCapture ¶
func (*Context) StartRender ¶
func (self *Context) StartRender(renderer string, resolve js.ResolveFunc) error
func (*Context) StartSignature ¶
func (self *Context) StartSignature()
Calculating a signature from the body is not that great. It saves bandwidth but not computing resources, as we still need to generate the body in order to calculate the signature. Ideally, the signature should be based on the data sources used to generate the page.
https://www.mnot.net/blog/2007/08/07/etags http://www.tbray.org/ongoing/When/200x/2007/07/31/Design-for-the-Web
func (*Context) StoreCachedRepresentation ¶
func (*Context) StoreCachedRepresentationFromBody ¶
func (self *Context) StoreCachedRepresentationFromBody(encoding platform.EncodingType, body []byte)
func (*Context) WriteCachedRepresentation ¶
type EncodeWriter ¶
type EncodeWriter struct {
// contains filtered or unexported fields
}
func NewEncodeWriter ¶
func NewEncodeWriter(writer io.Writer, type_ platform.EncodingType) *EncodeWriter
func (*EncodeWriter) GetWrappedWriter ¶
func (self *EncodeWriter) GetWrappedWriter() io.Writer
WrappingWriter interface
type Facet ¶
type Facet struct {
*Route
Representations Representations
}
func (*Facet) FindRepresentation ¶
func (self *Facet) FindRepresentation(context *Context) (*Representation, string, bool)
type HandleFunc ¶
func GetHandleFunc ¶
func GetHandleFunc(value interface{}) (HandleFunc, error)
type HashWriter ¶
type HashWriter struct {
// contains filtered or unexported fields
}
func NewHashWriter ¶
func NewHashWriter(writer io.Writer) *HashWriter
func (*HashWriter) GetWrappedWriter ¶
func (self *HashWriter) GetWrappedWriter() io.Writer
WrappingWriter interface
func (*HashWriter) Hash ¶
func (self *HashWriter) Hash() string
type JavaScriptFunc ¶
type JavaScriptFunc = func(goja.FunctionCall) goja.Value
type PathTemplate ¶
func NewPathTemplate ¶
func NewPathTemplate(path string) (*PathTemplate, error)
type PathTemplates ¶
type PathTemplates []*PathTemplate
func NewPathTemplates ¶
func NewPathTemplates(paths ...string) (PathTemplates, error)
type RenderWriter ¶
type RenderWriter struct {
// contains filtered or unexported fields
}
func NewRenderWriter ¶
func NewRenderWriter(writer io.Writer, renderer string, resolve js.ResolveFunc) (*RenderWriter, error)
func (*RenderWriter) GetWrappedWriter ¶
func (self *RenderWriter) GetWrappedWriter() io.Writer
WrappingWriter interface
type Representation ¶
type Representation struct {
Construct RepresentionFunc
Describe RepresentionFunc
Present RepresentionFunc
Erase RepresentionFunc
Modify RepresentionFunc
Call RepresentionFunc
}
func CreateRepresentation ¶
func (*Representation) Handle ¶
func (self *Representation) Handle(context *Context) bool
Handler interface HandleFunc signature
type RepresentionFunc ¶
func NewRepresentationFunc ¶
func NewRepresentationFunc(function interface{}, runtime *goja.Runtime) (RepresentionFunc, error)
type Resource ¶
func NewResource ¶
type Route ¶
type Route struct {
Name string
PathTemplates PathTemplates
Handler HandleFunc
}
type Router ¶
type Router struct {
Name string
Handlers []HandleFunc
Routes []*Route
}
func (*Router) AddHandler ¶
func (self *Router) AddHandler(handler HandleFunc)
type Server ¶
type Server struct {
Name string
Address string
Protocol string
Secure bool
Debug bool
Handler HandleFunc
// contains filtered or unexported fields
}
func (*Server) Handle ¶
func (self *Server) Handle(context *fasthttp.RequestCtx)
fasthttp.RequestHandler signature
type Static ¶
type Static struct {
RequestHandler fasthttp.RequestHandler
// contains filtered or unexported fields
}
type WrappingWriter ¶
type WrappingWriter interface {
io.WriteCloser
GetWrappedWriter() io.Writer
}
Click to show internal directories.
Click to hide internal directories.