Documentation ¶
Index ¶
- Constants
- Variables
- func CreateCookie(config ard.StringMap, context *js.Context) (interface{}, error)
- 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 SetBestEncodeWriter(context *Context)
- type CaptureFunc
- type CaptureWriter
- type ContentType
- type ContentTypePreference
- type ContentTypePreferences
- type Context
- func (self *Context) AddName(name string) *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) GetCachedRepresentationBody(cached *platform.CachedRepresentation) ([]byte, bool)
- func (self *Context) InternalServerError(err error)
- 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) Redirect(url string, status int) error
- 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) WriteJson(value ard.Value, indent string) (int, error)
- func (self *Context) WriteString(s string) (int, error)
- func (self *Context) WriteYaml(value ard.Value, indent string) (int, error)
- type EncodeWriter
- type EncodingPreference
- type EncodingPreferences
- type Facet
- type HandleFunc
- type Handler
- type HashWriter
- type PathTemplate
- type PathTemplates
- type RenderWriter
- type Representation
- type RepresentationEntry
- type Representations
- type RepresentionFunc
- type Request
- type Resource
- type Response
- type ResponseWriterWrapper
- type Route
- type Router
- type Server
- type Static
- type WrappingWriter
Constants ¶
const ( HeaderAccept = "Accept" HeaderAcceptEncoding = "Accept-Encoding" HeaderCacheControl = "Cache-Control" HeaderContentEncoding = "Content-Encoding" HeaderContentType = "Content-Type" HeaderETag = "ETag" HeaderIfModifiedSince = "If-Modified-Since" HeaderIfNoneMatch = "If-None-Match" HeaderLastModified = "Last-Modified" HeaderLocation = "Location" HeaderPrudenceCached = "X-Prudence-Cached" HeaderServer = "Server" )
const ( PathVariable = "__path" ParthVariableRe = `(?P<` + PathVariable + `>.*)` )
Variables ¶
var DefaultNotFound defaultNotFound
var PathTemplateAll = &PathTemplate{"", nil}
Functions ¶
func CreateCookie ¶ added in v1.0.3
CreateFunc signature
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 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 ContentType ¶ added in v1.0.3
func NewContentType ¶ added in v1.0.3
func NewContentType(name string) ContentType
func (ContentType) String ¶ added in v1.0.3
func (self ContentType) String() string
fmt.Stringify interface
type ContentTypePreference ¶ added in v1.0.3
type ContentTypePreference struct { ContentType Weight float64 }
func ParseContentTypePreference ¶ added in v1.0.3
func ParseContentTypePreference(text string) (ContentTypePreference, error)
func (*ContentTypePreference) Matches ¶ added in v1.0.3
func (self *ContentTypePreference) Matches(contentType ContentType, matchWildcard bool) bool
func (ContentTypePreference) String ¶ added in v1.0.3
func (self ContentTypePreference) String() string
fmt.Stringify interface
type ContentTypePreferences ¶ added in v1.0.3
type ContentTypePreferences []ContentTypePreference
func ParseContentTypePreferences ¶ added in v1.0.3
func ParseContentTypePreferences(text string) ContentTypePreferences
func (ContentTypePreferences) Len ¶ added in v1.0.3
func (self ContentTypePreferences) Len() int
sort.Interface interface
func (ContentTypePreferences) Less ¶ added in v1.0.3
func (self ContentTypePreferences) Less(i int, j int) bool
sort.Interface interface
func (ContentTypePreferences) Swap ¶ added in v1.0.3
func (self ContentTypePreferences) Swap(i int, j int)
sort.Interface 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) InternalServerError ¶ added in v1.0.3
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 EncodingPreference ¶ added in v1.0.3
type EncodingPreference struct { Name string Type platform.EncodingType Weight float64 }
func ParseEncodingPreference ¶ added in v1.0.3
func ParseEncodingPreference(text string) (EncodingPreference, error)
func (EncodingPreference) String ¶ added in v1.0.3
func (self EncodingPreference) String() string
fmt.Stringify interface
type EncodingPreferences ¶ added in v1.0.3
type EncodingPreferences []EncodingPreference
func ParseEncodingPreferences ¶ added in v1.0.3
func ParseEncodingPreferences(text string) EncodingPreferences
func (EncodingPreferences) Len ¶ added in v1.0.3
func (self EncodingPreferences) Len() int
sort.Interface interface
func (EncodingPreferences) Less ¶ added in v1.0.3
func (self EncodingPreferences) Less(i int, j int) bool
sort.Interface interface
func (EncodingPreferences) NegotiateBest ¶ added in v1.0.3
func (self EncodingPreferences) NegotiateBest(context *Context) platform.EncodingType
func (EncodingPreferences) Swap ¶ added in v1.0.3
func (self EncodingPreferences) Swap(i int, j int)
sort.Interface interface
type Facet ¶
type Facet struct { *Route Representations *Representations }
type HandleFunc ¶
func GetHandleFunc ¶
func GetHandleFunc(value interface{}, jsContext *js.Context) (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 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 RepresentationEntry ¶ added in v1.0.3
type RepresentationEntry struct { ContentType ContentType Representation *Representation }
type Representations ¶
type Representations struct {
Entries []*RepresentationEntry
}
func CreateRepresentations ¶
func (*Representations) Add ¶ added in v1.0.3
func (self *Representations) Add(contentType ContentType, representation *Representation)
func (*Representations) NegotiateBest ¶ added in v1.0.3
func (self *Representations) NegotiateBest(context *Context) (*Representation, string, bool)
type RepresentionFunc ¶
func NewRepresentationFunc ¶
func NewRepresentationFunc(function interface{}, jsContext *js.Context) (RepresentionFunc, error)
type Request ¶ added in v1.0.2
type Request struct { Host string Port int Header http.Header Method string Query url.Values Cookies []*http.Cookie 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 Cookies []*http.Cookie ContentType string CharSet string Language string Signature string WeakSignature bool Timestamp time.Time Buffer *bytes.Buffer Bypass bool Direct http.ResponseWriter }
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 NCSAPrefix string Debug bool Handler HandleFunc // contains filtered or unexported fields }
type WrappingWriter ¶
type WrappingWriter interface { io.WriteCloser GetWrappedWriter() io.Writer }