Documentation ¶
Index ¶
- Constants
- Variables
- func NewLogger() log.Logger
- type CertificateManager
- type Context
- func (ctx *Context) ActiveTransaction() *dbx.Trx
- func (ctx *Context) AddAuthCookie(user *models.User) (string, error)
- func (ctx *Context) AddCookie(name, value string, expires time.Time)
- func (ctx *Context) AddParam(name, value string)
- func (ctx *Context) AddRenderVar(name string, value interface{})
- func (ctx *Context) AuthEndpoint() string
- func (ctx *Context) BadRequest(dict Map) error
- func (ctx *Context) BaseURL() string
- func (ctx *Context) BindTo(i actions.Actionable) *validate.Result
- func (ctx *Context) Blob(code int, contentType string, b []byte) error
- func (ctx *Context) Cookie(name string) (*http.Cookie, error)
- func (ctx *Context) Failure(err error) error
- func (ctx *Context) Get(key string) interface{}
- func (ctx *Context) HandleValidation(result *validate.Result) error
- func (ctx *Context) IsAjax() bool
- func (ctx *Context) IsAuthenticated() bool
- func (ctx *Context) JSON(code int, i interface{}) error
- func (ctx *Context) Logger() log.Logger
- func (ctx *Context) NoContent(code int) error
- func (ctx *Context) NotFound() error
- func (ctx *Context) Ok(data interface{}) error
- func (ctx *Context) Page(dict Map) error
- func (ctx *Context) Param(name string) string
- func (ctx *Context) ParamAsInt(name string) (int, error)
- func (ctx *Context) QueryParam(key string) string
- func (ctx *Context) Redirect(code int, url string) error
- func (ctx *Context) RemoveCookie(name string)
- func (ctx *Context) Render(code int, template string, data Map) error
- func (ctx *Context) RenderVars() Map
- func (ctx *Context) Services() *app.Services
- func (ctx *Context) Set(key string, val interface{})
- func (ctx *Context) SetActiveTransaction(trx *dbx.Trx)
- func (ctx *Context) SetCookie(cookie *http.Cookie)
- func (ctx *Context) SetServices(services *app.Services)
- func (ctx *Context) SetTenant(tenant *models.Tenant)
- func (ctx *Context) SetUser(user *models.User)
- func (ctx *Context) String(code int, text string) error
- func (ctx *Context) Tenant() *models.Tenant
- func (ctx *Context) TenantBaseURL(tenant *models.Tenant) string
- func (ctx *Context) Unauthorized() error
- func (ctx *Context) User() *models.User
- type DefaultBinder
- type Engine
- type Group
- type HandlerFunc
- type Map
- type MiddlewareFunc
- type Renderer
- type StringMap
Constants ¶
const CookieAuthName = "auth"
CookieAuthName is the name of the authentication cookie
Variables ¶
var ( PlainContentType = "text/plain" HTMLContentType = "text/html" JSONContentType = "application/json" UTF8PlainContentType = PlainContentType + "; charset=utf-8" UTF8HTMLContentType = HTMLContentType + "; charset=utf-8" UTF8JSONContentType = JSONContentType + "; charset=utf-8" )
HTMLMimeType is the mimetype for HTML responses
var ( //ErrContentTypeNotAllowed is used when POSTing a body that is not json ErrContentTypeNotAllowed = errors.New("Only Content-Type application/json is allowed") )
Functions ¶
Types ¶
type CertificateManager ¶ added in v0.7.0
type CertificateManager struct {
// contains filtered or unexported fields
}
CertificateManager is used to manage SSL certificates
func NewCertificateManager ¶ added in v0.7.0
func NewCertificateManager(certFile, keyFile, cacheDir string) (*CertificateManager, error)
NewCertificateManager creates a new CertificateManager
func (*CertificateManager) GetCertificate ¶ added in v0.7.0
func (m *CertificateManager) GetCertificate(hello *tls.ClientHelloInfo) (*tls.Certificate, error)
GetCertificate decides which certificate to use It first tries to use loaded certificate for incoming request if it's compatible Otherwise fallsback to a automatically generated certificate by Let's Encrypt
func (*CertificateManager) StartHTTPServer ¶ added in v0.9.0
func (m *CertificateManager) StartHTTPServer()
StartHTTPServer creates a new HTTP server on port 80 that is used for the ACME HTTP Challenge
type Context ¶
type Context struct { Response http.ResponseWriter Request *http.Request // contains filtered or unexported fields }
Context shared between http pipeline
func (*Context) ActiveTransaction ¶
ActiveTransaction returns current active Database transaction
func (*Context) AddAuthCookie ¶ added in v0.6.0
AddAuthCookie generates and adds a cookie
func (*Context) AddRenderVar ¶
AddRenderVar register given key/value to RenderVar map
func (*Context) BadRequest ¶
BadRequest returns 400 BadRequest with JSON result
func (*Context) BindTo ¶ added in v0.4.0
func (ctx *Context) BindTo(i actions.Actionable) *validate.Result
BindTo context values into given model
func (*Context) Blob ¶ added in v0.7.0
Blob sends a blob response with status code and content type.
func (*Context) HandleValidation ¶ added in v0.4.0
HandleValidation handles given validation result property to return 400 or 500
func (*Context) IsAuthenticated ¶
IsAuthenticated returns true if user is authenticated
func (*Context) NoContent ¶ added in v0.7.0
NoContent sends a response with no body and a status code.
func (*Context) ParamAsInt ¶
ParamAsInt returns parameter as int
func (*Context) QueryParam ¶ added in v0.7.0
QueryParam returns querystring parameter for given key
func (*Context) Redirect ¶ added in v0.7.0
Redirect redirects the request to a provided URL with status code.
func (*Context) RemoveCookie ¶ added in v0.6.0
RemoveCookie removes a cookie
func (*Context) Render ¶ added in v0.7.0
Render renders a template with data and sends a text/html response with status
func (*Context) RenderVars ¶
RenderVars returns all registered RenderVar
func (*Context) SetActiveTransaction ¶
SetActiveTransaction adds transaction to context
func (*Context) SetServices ¶
SetServices update current context with app.Services
func (*Context) TenantBaseURL ¶ added in v0.6.0
TenantBaseURL returns base URL for a given tenant
func (*Context) Unauthorized ¶ added in v0.4.0
Unauthorized returns a 403 response
type DefaultBinder ¶ added in v0.7.0
type DefaultBinder struct { }
DefaultBinder is the default HTTP binder
func NewDefaultBinder ¶ added in v0.7.0
func NewDefaultBinder() *DefaultBinder
NewDefaultBinder creates a new default binder
func (*DefaultBinder) Bind ¶ added in v0.7.0
func (b *DefaultBinder) Bind(target interface{}, c *Context) error
Bind request data to object i
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is our web engine wrapper
func (*Engine) NewContext ¶
NewContext creates and return a new context
func (*Engine) Use ¶
func (e *Engine) Use(middleware MiddlewareFunc)
Use adds a middleware to the root engine
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group is our router group wrapper
func (*Group) Delete ¶ added in v0.8.0
func (g *Group) Delete(path string, handler HandlerFunc)
Delete handles HTTP DELETE requests
func (*Group) Get ¶
func (g *Group) Get(path string, handler HandlerFunc)
Get handles HTTP GET requests
func (*Group) Post ¶
func (g *Group) Post(path string, handler HandlerFunc)
Post handles HTTP POST requests
func (*Group) Use ¶
func (g *Group) Use(middleware MiddlewareFunc)
Use adds a middleware to current route stack
type Map ¶ added in v0.4.0
type Map map[string]interface{}
Map defines a generic map of type `map[string]interface{}`.
type MiddlewareFunc ¶
type MiddlewareFunc func(HandlerFunc) HandlerFunc
MiddlewareFunc represents an HTTP middleware
type Renderer ¶ added in v0.7.0
type Renderer struct {
// contains filtered or unexported fields
}
Renderer is the default HTML Render
func NewRenderer ¶ added in v0.7.0
func NewRenderer(settings *models.AppSettings, logger log.Logger) *Renderer
NewRenderer creates a new Renderer