web

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2017 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLogger

func NewLogger() *log.Logger

NewLogger creates a new logger

Types

type Context

type Context struct {
	echo.Context
}

Context wraps echo.context to provide userful information

func (*Context) ActiveTransaction

func (ctx *Context) ActiveTransaction() *dbx.Trx

ActiveTransaction returns current active Database transaction

func (*Context) AddRenderVar

func (ctx *Context) AddRenderVar(name string, value interface{})

AddRenderVar register given key/value to RenderVar map

func (*Context) AuthEndpoint

func (ctx *Context) AuthEndpoint() string

AuthEndpoint auth endpoint

func (*Context) BadRequest

func (ctx *Context) BadRequest(dict echo.Map) error

BadRequest returns 400 BadRequest with JSON result

func (*Context) BaseURL

func (ctx *Context) BaseURL() string

BaseURL returns base URL as string

func (*Context) Failure

func (ctx *Context) Failure(err error) error

Failure returns a 500 page

func (*Context) IsAjax

func (ctx *Context) IsAjax() bool

IsAjax returns true if request is AJAX

func (*Context) IsAuthenticated

func (ctx *Context) IsAuthenticated() bool

IsAuthenticated returns true if user is authenticated

func (*Context) NotFound

func (ctx *Context) NotFound() error

NotFound returns a 404 page

func (*Context) Ok

func (ctx *Context) Ok(dict echo.Map) error

Ok returns 200 OK with JSON result

func (*Context) Page

func (ctx *Context) Page(dict echo.Map) error

Page returns a page with given variables

func (*Context) ParamAsInt

func (ctx *Context) ParamAsInt(name string) (int, error)

ParamAsInt returns parameter as int

func (*Context) RenderVars

func (ctx *Context) RenderVars() echo.Map

RenderVars returns all registered RenderVar

func (*Context) Services

func (ctx *Context) Services() *app.Services

Services returns current app.Services from context

func (*Context) SetActiveTransaction

func (ctx *Context) SetActiveTransaction(trx *dbx.Trx)

SetActiveTransaction adds transaction to context

func (*Context) SetServices

func (ctx *Context) SetServices(services *app.Services)

SetServices update current context with app.Services

func (*Context) SetTenant

func (ctx *Context) SetTenant(tenant *models.Tenant)

SetTenant update HTTP context with current tenant

func (*Context) SetUser

func (ctx *Context) SetUser(user *models.User)

SetUser update HTTP context with current user

func (*Context) Tenant

func (ctx *Context) Tenant() *models.Tenant

Tenant returns current tenant

func (*Context) User

func (ctx *Context) User() *models.User

User returns authenticated user

type Engine

type Engine struct {
	Logger *log.Logger
	// contains filtered or unexported fields
}

Engine is our web engine wrapper

func New

func New(settings *models.AppSettings) *Engine

New creates a new Engine

func (*Engine) Group

func (e *Engine) Group(preffix string) *Group

Group creates a new router group with prefix

func (*Engine) HandleError

func (e *Engine) HandleError(err error, ctx Context)

HandleError redirect error to router

func (*Engine) NewContext

func (e *Engine) NewContext(req *http.Request, w http.ResponseWriter) Context

NewContext creates and return a new context

func (*Engine) Start

func (e *Engine) Start(address string)

Start an HTTP server.

func (*Engine) Use

func (e *Engine) Use(middleware MiddlewareFunc)

Use middleware on root router

type Group

type Group struct {
	// contains filtered or unexported fields
}

Group is our router group wrapper

func (*Group) Get

func (g *Group) Get(path string, handler HandlerFunc)

Get handles HTTP GET requests

func (*Group) Group

func (g *Group) Group(preffix string) *Group

Group creates asub-group with prefix

func (*Group) Post

func (g *Group) Post(path string, handler HandlerFunc)

Post handles HTTP POST requests

func (*Group) Static

func (g *Group) Static(prefix, root string)

Static return files from given folder

func (*Group) Use

func (g *Group) Use(middleware MiddlewareFunc)

Use add middleware to sub-routes within the Group

type HTMLRenderer

type HTMLRenderer struct {
	// contains filtered or unexported fields
}

HTMLRenderer renderer

func NewHTMLRenderer

func NewHTMLRenderer(settings *models.AppSettings, logger echo.Logger) *HTMLRenderer

NewHTMLRenderer creates a new HTMLRenderer

func (*HTMLRenderer) Render

func (r *HTMLRenderer) Render(w io.Writer, name string, data interface{}, c echo.Context) error

Render a template based on parameters

type HandlerFunc

type HandlerFunc func(Context) error

HandlerFunc represents an HTTP handler

type MiddlewareFunc

type MiddlewareFunc func(HandlerFunc) HandlerFunc

MiddlewareFunc represents an HTTP middleware

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL