Documentation
¶
Index ¶
- Constants
- Variables
- 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 GetEncodingType(name string) platform.EncodingType
- func Handled(context *Context) bool
- func NegotiateBestEncodingType(header http.Header) platform.EncodingType
- func SetBestEncodeWriter(context *Context)
- type CaptureFunc
- type CaptureWriter
- type Context
- func (self *Context) Copy() *Context
- func (self *Context) DeleteCachedRepresentation()
- 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) StartCapture(name string)
- func (self *Context) StartRender(renderer string, jsContext *js.Context) 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 PathTemplate
- type PathTemplates
- type RenderWriter
- type Representation
- type Representations
- type RepresentionFunc
- type Request
- type Resource
- type Response
- type ResponseWriterWrapper
- type Route
- type Router
- type Server
- type Static
- type WrappingWriter
Constants ¶
View Source
const ( HeaderAccept = "Accept" HeaderAcceptEncoding = "Accept-Encoding" HeaderCacheControl = "Cache-Control" HeaderCached = "X-Prudence-Cached" HeaderContentEncoding = "Content-Encoding" HeaderContentType = "Content-Type" HeaderETag = "ETag" HeaderIfModifiedSince = "If-Modified-Since" HeaderIfNoneMatch = "If-None-Match" HeaderLastModified = "Last-Modified" HeaderServer = "Server" )
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 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 GetEncodingType ¶
func GetEncodingType(name string) platform.EncodingType
func NegotiateBestEncodingType ¶ added in v1.0.2
func NegotiateBestEncodingType(header http.Header) platform.EncodingType
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 {
Request *Request
Response *Response
Log logging.Logger
Name string
Debug bool
Path string
Variables ard.StringMap
Done bool
Created bool
Async bool
CacheDuration float64 // seconds
CacheKey string
CacheGroups []string
// contains filtered or unexported fields
}
func NewContext ¶
func NewContext(responseWriter http.ResponseWriter, request *http.Request) *Context
func (*Context) DeleteCachedRepresentation ¶
func (self *Context) DeleteCachedRepresentation()
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 (*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) NegotiateBestRepresentation ¶ added in v1.0.2
func (self *Facet) NegotiateBestRepresentation(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 (*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 Request ¶ added in v1.0.2
type Request struct {
URL *url.URL
Header http.Header
Method string
Query url.Values
Body string
Direct *http.Request
}
func NewRequest ¶ added in v1.0.2
type Resource ¶
func NewResource ¶
type Response ¶ added in v1.0.2
type Response struct {
Status int
Header http.Header
ContentType string
CharSet string
Language string
Signature string
WeakSignature bool
Timestamp time.Time
Direct http.ResponseWriter
Buffer *bytes.Buffer
Bypass bool
}
func NewResponse ¶ added in v1.0.2
func NewResponse(responseWriter http.ResponseWriter) *Response
type ResponseWriterWrapper ¶ added in v1.0.2
type ResponseWriterWrapper struct {
http.ResponseWriter
// contains filtered or unexported fields
}
func NewResponseWriterWrapper ¶ added in v1.0.2
func NewResponseWriterWrapper(context *Context) *ResponseWriterWrapper
func (*ResponseWriterWrapper) Write ¶ added in v1.0.2
func (self *ResponseWriterWrapper) Write(p []byte) (int, error)
func (*ResponseWriterWrapper) WriteHeader ¶ added in v1.0.2
func (self *ResponseWriterWrapper) WriteHeader(status int)
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
Secure bool
Certificate string
Key string
Debug bool
Handler HandleFunc
// 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.