Documentation
¶
Overview ¶
Package fuse is a web framework with sane conventions. These conventions remove some of the boilerplate that naturally arises from using Go for web development. Fuse automatically:
- serves files from the public directory
- loads templates from the template directory
- loads and saves sessions
This means that each controller is more succinct and to the point.
Index ¶
- func Logger(c *Context)
- type Context
- type Engine
- func (e *Engine) DELETE(path string, handler Handler)
- func (e *Engine) GET(path string, handler Handler)
- func (e *Engine) HEAD(path string, handler Handler)
- func (e *Engine) POST(path string, handler Handler)
- func (e *Engine) PUT(path string, handler Handler)
- func (e *Engine) Run(addr string)
- func (e *Engine) Use(handler Handler)
- type Handler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Context ¶
type Context struct {
// Request is the original http.Request.
Request *http.Request
// ResponseWriter is the original http.ResponseWriter.
ResponseWriter http.ResponseWriter
// Params is a map of the path parameters.
Params map[string]string
// Form holds all of the form data from the URL query and the POST/PUT
// data.
Form url.Values
// PostForm holds only the POST/PUT data.
PostForm url.Values
// InData provides a way for middleware to pass data to handlers.
InData map[string]interface{}
// OutData is used to render dynamic content. Calls to Context.Html and
// Context.Json use this data.
OutData map[string]interface{}
// Session contains the current request's session data.
Session map[interface{}]interface{}
// contains filtered or unexported fields
}
Context holds all necessary information about an incoming request.
func (*Context) Html ¶
Html executes the named template with the given HTTP code. It uses the context's OutData in the template.
func (*Context) HtmlOk ¶
Html executes the named template with the 200 OK HTTP code. It uses the context's OutData in the template.
func (*Context) JsonOk ¶
func (c *Context) JsonOk()
Json encodes the context's OutData to JSON with the 200 OK HTTP code.
func (*Context) Next ¶
func (c *Context) Next()
Next calls the next middleware in the chain. If called from the handler, it will panic.
func (*Context) SeeOther ¶
SeeOther redirects the request to the location using the 303 See Other HTTP code.
type Engine ¶
type Engine struct {
// NotFound is called whenever a request comes in that isn't mapped to a
// handler and doesn't correspond to a file name in the public directory.
NotFound Handler
// Panic is called whenever a request panics.
Panic Handler
// PublicDir is the directory which holds all files that are publicly
// accessible. The default is "public".
PublicDir string
// TempalteGlob is the glob that defines which files to parse as HTML
// templates. The default is "templates/*.tpl"
TemplateGlob string
// contains filtered or unexported fields
}
Engine is the Fuse server. It should always be created using the fuse.New function.
func (*Engine) DELETE ¶
DELETE defines a route for DELETE requests to the handler. See GET for information about path parameters.
func (*Engine) GET ¶
GET defines a route for GET requests to the handler. The path can contain parameters prefixed with a colon (:). For example, the following requests would all be routed to the handler if we define the path as /user/:name
/user/foo /user/bar /user/baz
However, the following paths would not be routed.
/user /user/ /user/foo/profile /profile/user/foo
func (*Engine) HEAD ¶
HEAD defines a route for HEAD requests to the handler. See GET for information about path parameters.
func (*Engine) POST ¶
POST defines a route for POST requests to the handler. See GET for information about path parameters.