Documentation
¶
Index ¶
- Variables
- type CHandler
- type Context
- func (ctx *Context) AnonymousTemplate(tmpl *template.Template)
- func (ctx *Context) BadRequest()
- func (ctx *Context) EmptyOK()
- func (ctx *Context) ExecuteBaseTemplate(templateName string)
- func (ctx *Context) ExecuteTemplate(templateName string)
- func (ctx *Context) Forbidden()
- func (ctx *Context) HTML(output string)
- func (ctx *Context) JSON(output []byte)
- func (ctx *Context) NotFound()
- func (ctx *Context) Redirect(location string, status ...int)
- func (ctx *Context) String(output string)
- type DefaultAuth
- type Enliven
- func (ev *Enliven) AddApp(app IApp)
- func (ev *Enliven) AddMiddleware(handler IMiddlewareHandler)
- func (ev *Enliven) AddMiddlewareFunc(handlerFunc func(*Context, NextHandlerFunc))
- func (ev *Enliven) AddRoute(path string, rhf func(*Context), methods ...string) *mux.Route
- func (ev *Enliven) AddService(name string, service interface{})
- func (ev *Enliven) AppInstalled(name string) bool
- func (ev *Enliven) GetService(name string) interface{}
- func (ev *Enliven) MiddlewareInstalled(name string) bool
- func (ev *Enliven) Run()
- type HandlerFunc
- type IApp
- type IAuthorizer
- type IMiddlewareHandler
- type ISession
- type Middleware
- type NextHandlerFunc
- type RouteHandlerFunc
Constants ¶
This section is empty.
Variables ¶
var DefaultEnlivenConfig = config.Config{
"email_smtp_identity": "",
"email_smtp_username": "",
"email_smtp_password": "",
"email_smtp_host": "",
"email_smtp_port": "25",
"email_from_default": "",
"email_smtp_auth": "plain",
"email_allow_insecure": "0",
"server_address": ":8000",
"site_name": "Enliven",
"site_url": "http://localhost:8000",
}
DefaultEnlivenConfig represents the default config for enliven
Functions ¶
This section is empty.
Types ¶
type CHandler ¶
type CHandler func(*Context)
CHandler Handles injecting the initial request context before passing handling on to the Middleware struct
func ContextHandler ¶
func ContextHandler(h Middleware) CHandler
ContextHandler sets up serving the first request, and the handing off of subsequent requests to the Middleware struct
type Context ¶
type Context struct { Session ISession Vars map[string]string // This map specifically to hold route key value pairs. Strings map[string]string Integers map[string]int Booleans map[string]bool Storage map[string]interface{} Enliven *Enliven Response http.ResponseWriter Request *http.Request }
Context stores context variables and the session that will be passed to requests
func (*Context) AnonymousTemplate ¶
AnonymousTemplate sets up HTML headers and outputs an html/template response
func (*Context) BadRequest ¶
func (ctx *Context) BadRequest()
BadRequest returns a 400 status and the bad-request page
func (*Context) EmptyOK ¶
func (ctx *Context) EmptyOK()
EmptyOK outputs a 200 status with nothing else
func (*Context) ExecuteBaseTemplate ¶
ExecuteBaseTemplate sets up HTML headers and outputs an html/template response for a specific template definition
func (*Context) ExecuteTemplate ¶
ExecuteTemplate gets a specific template from our list of templates and executes it
func (*Context) Forbidden ¶
func (ctx *Context) Forbidden()
Forbidden returns a 403 status and the forbidden page.
func (*Context) JSON ¶
JSON sets up JSON headers and outputs a JSON response Expects to recieve the result of json marshalling ([]byte)
func (*Context) NotFound ¶
func (ctx *Context) NotFound()
NotFound returns a 404 status and the not-found page
type DefaultAuth ¶
type DefaultAuth struct{}
DefaultAuth is a simple implementation of IAuthorizer to stand in for auth checking/adding This should be overridden by the user app or something else if permissions checking is needed.
func (*DefaultAuth) AddPermission ¶
func (da *DefaultAuth) AddPermission(permission string, ev *Enliven, groups ...string)
AddPermission is the default permission adder, and does nothing.
func (*DefaultAuth) HasPermission ¶
func (da *DefaultAuth) HasPermission(permission string, ctx *Context) bool
HasPermission is the default permission checker and always returns true
type Enliven ¶
type Enliven struct { Auth IAuthorizer Core core.Core Router *mux.Router // contains filtered or unexported fields }
Enliven is....Enliven
func (*Enliven) AddMiddleware ¶
func (ev *Enliven) AddMiddleware(handler IMiddlewareHandler)
AddMiddleware adds a Handler onto the middleware stack. Copied w/ alterations from github.com/codegangsta/negroni
func (*Enliven) AddMiddlewareFunc ¶
func (ev *Enliven) AddMiddlewareFunc(handlerFunc func(*Context, NextHandlerFunc))
AddMiddlewareFunc adds a HandlerFunc onto the middleware stack. Copied w/ alterations from github.com/codegangsta/negroni
func (*Enliven) AddRoute ¶
AddRoute Registers a handler for a given route. We register a dummy route with mux, and then store the provided handler which we'll use later in order to inject dependencies into the handler func.
func (*Enliven) AddService ¶
AddService registers an enliven service or dependency
func (*Enliven) AppInstalled ¶
AppInstalled returns true if a given app has already been installed
func (*Enliven) GetService ¶
GetService returns an enliven service or dependency
func (*Enliven) MiddlewareInstalled ¶
MiddlewareInstalled returns true if a given middleware has already been installed
type HandlerFunc ¶
type HandlerFunc func(*Context, NextHandlerFunc)
HandlerFunc allow use of ordinary functions middleware handlers Copied w/ alterations from github.com/codegangsta/negroni
func (HandlerFunc) GetName ¶
func (h HandlerFunc) GetName() string
GetName returns an empty string for this function middleware
func (HandlerFunc) Initialize ¶
func (h HandlerFunc) Initialize(ev *Enliven)
Initialize initializes this function middleware by doing nothing
func (HandlerFunc) ServeHTTP ¶
func (h HandlerFunc) ServeHTTP(ctx *Context, next NextHandlerFunc)
Copied w/ alterations from github.com/codegangsta/negroni
type IApp ¶
IApp is an interface for writing Enliven apps Apps are basically packaged code to extend Enliven's functionality
type IAuthorizer ¶
type IAuthorizer interface { HasPermission(string, *Context) bool // Name of the new permission, the enliven instance, groups that we want to add permission to AddPermission(string, *Enliven, ...string) }
IAuthorizer is an interface to be used when writing a struct for checking a permission
type IMiddlewareHandler ¶
type IMiddlewareHandler interface { Initialize(*Enliven) GetName() string ServeHTTP(*Context, NextHandlerFunc) }
IMiddlewareHandler is an interface to be used when writing Middleware Copied w/ alterations from github.com/codegangsta/negroni
type ISession ¶
type ISession interface { Set(key string, value string) error Get(key string) string Delete(key string) error Destroy() error SessionID() string }
ISession represents a session that session middleware must implement
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware Represents a piece of middlewear Copied w/ alterations from github.com/codegangsta/negroni
func (Middleware) ServeHTTP ¶
func (m Middleware) ServeHTTP(ctx *Context)
Copied w/ alterations from github.com/codegangsta/negroni
type NextHandlerFunc ¶
type NextHandlerFunc func(*Context)
NextHandlerFunc allow use of ordinary functions middleware handlers Copied w/ alterations from github.com/codegangsta/negroni
func (NextHandlerFunc) ServeHTTP ¶
func (nh NextHandlerFunc) ServeHTTP(ctx *Context)
Copied w/ alterations from github.com/codegangsta/negroni
type RouteHandlerFunc ¶
type RouteHandlerFunc func(*Context)
RouteHandlerFunc is an interface to be used when writing route handler functions