Documentation ¶
Overview ¶
Package zaiuz provides glue code implementation that ties together various components of the excellent Gorilla web toolkit (http://www.gorillatoolkit.org) to make developing typical MVC-style website faster and easier using as many common conventions as will not clutter the package.
Index ¶
- Constants
- type Action
- type Context
- type Filter
- type Hash
- type Key
- type NullKey
- type Result
- type Router
- func (router *Router) Filters() []Filter
- func (router *Router) Get(path string, action Action) *Router
- func (router *Router) GetPost(path string, action Action) *Router
- func (router *Router) Include(filters ...Filter)
- func (router *Router) Parent() *Router
- func (router *Router) Post(path string, action Action) *Router
- func (router *Router) Router() *mux.Router
- func (router *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (router *Router) Static(urlPath, filePath string) *Router
- func (router *Router) Subrouter(path string) *Router
Constants ¶
const InitialContextCapacity = 4
Initial capacity for the context internal storage.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
Action is the main interaction unit of zaiuz. This is zaiuz's analog to the standard http.ServeHTTP method. Most methods that work on the Context should follows the same function signature.
type Context ¶
type Context struct { Request *http.Request ResponseWriter http.ResponseWriter // contains filtered or unexported fields }
The basic Context structure encapsulates request and response objects that would normally be supplied to a http.ServeHTTP method as well as encapsulating a small map for storing and passing data between modules inside a single request execution context.
func NewContext ¶
func NewContext(w http.ResponseWriter, r *http.Request) *Context
Creates a new context.
func (*Context) GetOk ¶
Gets an object from the context tied to the specified key, also returns an additional boolean indicating wether the get was successful.
type Filter ¶
ActionFilter provides a way to wraps an existing actions to modifies or adds to the functionality. ActionFilter is functionally equivalent to traditional middlewares.
type Hash ¶
type Hash string
Represents a hashed string usually used for storing passwords. This type implements driver.Valuer and sql.Scanner so you can use this as your model's password hash type directly. The underlying algorithm use google's bcrypt library.
func (Hash) MatchOriginal ¶
Returns wether or not the receiver hash is the hash of the given original string. Use this method to compare user's password input with stored hash value.
type Key ¶
type Key string
Represents a GUID database key. This type implements driver.Valuer and sql.Scanner so you can use this as your model's Key type directly.
type NullKey ¶
type NullKey struct{ sql.NullString }
Analog to sql.NullString for Key
func NewNullKey ¶
func NewNullKey() NullKey
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router is a wrapper over Gorrila web toolkit's mux router (http://www.gorillatoolkit.org/pkg/mux) that provides helpers that work with standard zaiuz Action function signature as well as Filters.
func (*Router) Filters ¶
Retreive all modules included into this router so far. Also resolve parent's list of modules if called from a subrouter.
func (*Router) Include ¶
Include a Filter in the current router for all mapped (and future) actions.
func (*Router) Parent ¶
Parent() method returns the parent router if this is a child router, or nil otherwise.