Documentation ¶
Overview ¶
Vincent is a lightweight Web framework for golang. Templates are written using Handlebars, and it supports routing and TLS.
For an example of use, please see http://github.com/tomdionysus/vincent-demo
Index ¶
- Constants
- func NewConnLimitListener(count int, l *net.TCPListener) net.Listener
- type BufferedResponseWriter
- type ConnLimitConn
- func (cll *ConnLimitConn) Close() error
- func (cll *ConnLimitConn) LocalAddr() net.Addr
- func (cll *ConnLimitConn) Read(b []byte) (int, error)
- func (cll *ConnLimitConn) RemoteAddr() net.Addr
- func (cll *ConnLimitConn) SetDeadline(t time.Time) error
- func (cll *ConnLimitConn) SetReadDeadline(t time.Time) error
- func (cll *ConnLimitConn) SetWriteDeadline(t time.Time) error
- func (cll *ConnLimitConn) Write(b []byte) (int, error)
- type ConnLimitListener
- type Context
- type Controller
- type FileSegment
- type Handler
- type HandlerFunc
- type ParamSegment
- type RouteSegment
- func (rsg *RouteSegment) Add(path string, handler Handler) error
- func (rsg *RouteSegment) AddController(path string, controller Controller)
- func (rsg *RouteSegment) CallControllers(context *Context) (bool, error)
- func (rsg *RouteSegment) Passthrough(path string, context *Context) (bool, error)
- func (rsg *RouteSegment) Render(path string, context *Context) (bool, error)
- func (rsg *RouteSegment) Walk(path string, fn RouteSegmentWalkFunc) bool
- type RouteSegmentWalkFunc
- type Server
- func (svr *Server) AddController(path string, controller Controller)
- func (svr *Server) LoadTemplates(routePrefix, basePath string) error
- func (svr *Server) ServeHTTP(wr http.ResponseWriter, r *http.Request)
- func (svr *Server) Start(addr string)
- func (svr *Server) StartTLS(addr, certFile, keyFile string)
- type TemplateSegment
Constants ¶
const VERSION = "0.0.1"
Variables ¶
This section is empty.
Functions ¶
func NewConnLimitListener ¶
func NewConnLimitListener(count int, l *net.TCPListener) net.Listener
Return a new ConnLimitListener using the supplied connection limit and underlying TCPListener
Types ¶
type BufferedResponseWriter ¶
A ResponseWriter that buffers everything written to it
func NewBufferedResponseWriter ¶
func NewBufferedResponseWriter() *BufferedResponseWriter
Return a new BufferedResponseWriter
func (*BufferedResponseWriter) FlushToResponseWriter ¶
func (brw *BufferedResponseWriter) FlushToResponseWriter(w http.ResponseWriter) error
Write HTTP Status, Headers and Flush all data to the supplied http.ResponseWriter
func (*BufferedResponseWriter) Header ¶
func (brw *BufferedResponseWriter) Header() http.Header
Return the current headers
func (*BufferedResponseWriter) Write ¶
func (brw *BufferedResponseWriter) Write(data []byte) (int, error)
Write the supplied data
func (*BufferedResponseWriter) WriteHeader ¶
func (brw *BufferedResponseWriter) WriteHeader(code int)
Set the HTTP status code
type ConnLimitConn ¶
type ConnLimitConn struct {
// contains filtered or unexported fields
}
A net.Conn for use with ConnLimitListener
func (*ConnLimitConn) Close ¶
func (cll *ConnLimitConn) Close() error
Close the underlying connection
func (*ConnLimitConn) LocalAddr ¶
func (cll *ConnLimitConn) LocalAddr() net.Addr
Return the LocalAddr of the underlying connection
func (*ConnLimitConn) Read ¶
func (cll *ConnLimitConn) Read(b []byte) (int, error)
Read from the underlying connection
func (*ConnLimitConn) RemoteAddr ¶
func (cll *ConnLimitConn) RemoteAddr() net.Addr
Return the RemoteAddr of the underlying connection
func (*ConnLimitConn) SetDeadline ¶
func (cll *ConnLimitConn) SetDeadline(t time.Time) error
Set the timeout deadline of the underlying connection
func (*ConnLimitConn) SetReadDeadline ¶
func (cll *ConnLimitConn) SetReadDeadline(t time.Time) error
Set the read timeout deadline of the underlying connection
func (*ConnLimitConn) SetWriteDeadline ¶
func (cll *ConnLimitConn) SetWriteDeadline(t time.Time) error
Set the write timeout deadline of the underlying connection
type ConnLimitListener ¶
type ConnLimitListener struct {
// contains filtered or unexported fields
}
A TCPListener that limits concurrent connections
func (*ConnLimitListener) Accept ¶
func (cll *ConnLimitListener) Accept() (net.Conn, error)
Block until a connection is available and the limit has not been reached, then accpt the connection and return it
func (*ConnLimitListener) Addr ¶
func (cll *ConnLimitListener) Addr() net.Addr
Return the underlying listener Address
func (*ConnLimitListener) Close ¶
func (cll *ConnLimitListener) Close() error
Close the underlying listener
type Context ¶
type Context struct { Server *Server Request *http.Request ResponseWriter http.ResponseWriter Params map[string]interface{} Input map[string]interface{} Output map[string]interface{} }
func NewContext ¶
type Controller ¶
type FileSegment ¶
type FileSegment struct { RouteSegment Filename string }
A segment of a route that repcontext.ResponseWriterents a raw file
func NewFileSegment ¶
func NewFileSegment(filename string) *FileSegment
Return a new FileSegment with the supplied filename
type Handler ¶
type Handler interface { Render(path string, context *Context) (bool, error) Passthrough(path string, context *Context) (bool, error) Add(path string, handler Handler) error AddController(path string, controller Controller) CallControllers(context *Context) (bool, error) Walk(path string, fn RouteSegmentWalkFunc) bool }
An interface that handles a Route segment
type HandlerFunc ¶
type HandlerFunc func(path string, req *http.Request, res http.ResponseWriter, context map[string]interface{}) (bool, error)
A function that handle a route segment
type ParamSegment ¶
type ParamSegment struct { RouteSegment ParamName string }
A segment of a route that represents a parameter
func NewParamSegment ¶
func NewParamSegment(paramName string) *ParamSegment
Return a new ParamSegment with the supplied name, e.g. "identity" or "identity.name"
type RouteSegment ¶
type RouteSegment struct { Server *Server Segments map[string]Handler Controllers []Controller }
Represents a single segment of a route, e.g. http://host:port/<segment>/<segment>...
func NewRouteSegment ¶
func NewRouteSegment(svr *Server) *RouteSegment
Return a new RouteSegment for the supplied server
func (*RouteSegment) Add ¶
func (rsg *RouteSegment) Add(path string, handler Handler) error
Add a route and handler to this segment at this segment's path
func (*RouteSegment) AddController ¶
func (rsg *RouteSegment) AddController(path string, controller Controller)
func (*RouteSegment) CallControllers ¶
func (rsg *RouteSegment) CallControllers(context *Context) (bool, error)
func (*RouteSegment) Passthrough ¶
func (rsg *RouteSegment) Passthrough(path string, context *Context) (bool, error)
Process the path and call Render on subroute handlers
func (*RouteSegment) Render ¶
func (rsg *RouteSegment) Render(path string, context *Context) (bool, error)
func (*RouteSegment) Walk ¶
func (rsg *RouteSegment) Walk(path string, fn RouteSegmentWalkFunc) bool
Walk the segment tree calling the supplied RouteSegmentWalkFunc for each possible route leaf
type RouteSegmentWalkFunc ¶
A function to walk the segment tree
type Server ¶
type Server struct { Log log.Logger Root *RouteSegment DefaultDocument string }
Server is a HTTP server for use with vincent projects.
func (*Server) AddController ¶
func (svr *Server) AddController(path string, controller Controller)
func (*Server) LoadTemplates ¶
Walk the supplied basePath directory and parse all files and templates into routes using the route prefix specified.
func (*Server) ServeHTTP ¶
func (svr *Server) ServeHTTP(wr http.ResponseWriter, r *http.Request)
Support the http.Handler ServeHTTP method. This is called once per request
type TemplateSegment ¶
type TemplateSegment struct { RouteSegment Template *raymond.Template }
A Segment representing a handlebars template
func NewTemplateSegment ¶
func NewTemplateSegment(template *raymond.Template) *TemplateSegment
Return a new TemplateSegment with the supplied raymond.Template