Documentation
¶
Index ¶
- type Context
- type Controller
- type CookieJar
- type EntrySet
- type Handler
- type Options
- type Request
- type Response
- func (r *Response) Bytes(body []byte) error
- func (r *Response) Cookie(cookie http.Cookie)
- func (r *Response) DestroyCookie(cookie http.Cookie)
- func (r *Response) End(statusCode int)
- func (r *Response) Ended() bool
- func (r *Response) File(path string) error
- func (r *Response) Header() http.Header
- func (r *Response) JSON(body interface{}) error
- func (r *Response) Locals() EntrySet
- func (r *Response) Redirect(url string)
- func (r *Response) Render(template *template.Template, context interface{}) error
- func (r *Response) Response() http.ResponseWriter
- func (r *Response) Server() *Server
- func (r *Response) String(body string) error
- type Router
- type Server
- func (s *Server) FindTemplate(name string) (*template.Template, error)
- func (s *Server) FindTemplateMust(name string) *template.Template
- func (s *Server) Listen()
- func (s *Server) RegisterController(controller Controller)
- func (s *Server) RegisterMiddleware(handler ...Handler)
- func (s *Server) Resource(path string) ([]byte, error)
- func (s *Server) ResourcePath(path string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
Context is the keyed data you want to give a template.
func NewContext ¶
NewContext creates a new context with optional inheritance from parent(s).
type Controller ¶
Controller -
type CookieJar ¶
CookieJar is an abstraction of the []*http.Cookie slice.
type EntrySet ¶
EntrySet is a map of keys and their string values.
type Options ¶
type Options struct {
Host string `json:"host"` // optional, defaults to localhost
Port int `json:"port"` // optional, defaults to 80
Directory string `json:"directory"` // optional, relative to current working directory
FriendlyExtensions []string `json:"friendlyURLs"` // optional, remove extension requirement in url
TemplateExtensions []string `json:"templateExtension"` // optional, which extension to associate with templates (.tmp is default)
Certificate string `json:"certificate"` // optional
Key string `json:"key"` // optional
}
Options are configurable server settings. All are optional and have default values.
type Request ¶
Request is an abstraction of the http.Request.
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
Response is an abstraction of the http.ResponseWriter.
func (*Response) DestroyCookie ¶
DestroyCookie removes the provided cookie from the session.
func (*Response) File ¶
File responds with a resource relative to the server directory. An extension is required to get the MIME type.
func (*Response) Response ¶
func (r *Response) Response() http.ResponseWriter
Response returns the original http.ResponseWriter of the request.
type Server ¶
type Server struct {
*Options
Middleware []Handler
Controllers []Controller
Template *template.Template
}
Server -
func (*Server) FindTemplate ¶
FindTemplate returns a defined template and errors if not found.
func (*Server) FindTemplateMust ¶
FindTemplateMust returns a defined template and panics if not found.
func (*Server) RegisterController ¶
func (s *Server) RegisterController(controller Controller)
RegisterController maps a path to a handler.
func (*Server) RegisterMiddleware ¶
RegisterMiddleware adds a new middleware to the server. The order in which middleware is added determines the execution order. Middleware will gets called before routing takes place.
func (*Server) Resource ¶
Resource fetches the raw bytes from a provided resource path. The path will be translated relative to specified the server directory.
func (*Server) ResourcePath ¶
ResourcePath fetches the relative to the requested file.