Documentation
¶
Index ¶
- Variables
- type AppConfig
- type Application
- func (app *Application) Assets() []Asset
- func (app Application) JSON(ctx Context, data interface{}) error
- func (app Application) NewContext(rc RouteConfig, w http.ResponseWriter, r *http.Request) Context
- func (app *Application) Serve()
- func (app Application) View(ctx Context, viewName string, data ViewData) error
- type Asset
- type AssetsConfigs
- type AuthUser
- type AuthUserType
- type Authentication
- func (auth Authentication) CompareOAuthState(ctx Context, state string) error
- func (auth Authentication) ComparePasswordAndHash(password, hash string) (match bool, err error)
- func (auth *Authentication) ExchangeAuthorisationCode(ctx Context, authorisationCode string) (OAuthResult, error)
- func (auth Authentication) GeneratePasswordHash(c *PasswordConfig, password string) (string, error)
- func (auth *Authentication) GetAuthUser(ctx Context) AuthUser
- func (auth *Authentication) GetAuthorizationUri(ctx Context) string
- type AuthenticationConfig
- type AuthenticationProvider
- type Context
- type Cookies
- type DatabaseConfig
- type DefaultConfiguration
- type DefaultContext
- func (d *DefaultContext) Bind(dst interface{}) error
- func (d *DefaultContext) Cookies() *Cookies
- func (d *DefaultContext) Data() map[string]interface{}
- func (d *DefaultContext) Flash() *Flash
- func (d *DefaultContext) Param(key string) string
- func (d *DefaultContext) Params() ParamValues
- func (d *DefaultContext) Request() *http.Request
- func (d *DefaultContext) Response() http.ResponseWriter
- func (d *DefaultContext) Session() *Session
- func (d *DefaultContext) Set(key string, value interface{})
- func (d *DefaultContext) Value(key interface{}) interface{}
- type ExchangeAuthorisationCodeRequest
- type FileExtension
- type Flash
- type Handler
- type JsonResponseBody
- type Middleware
- type MiddlewareFunc
- type MiddlewareRegistry
- type MiddlewareStack
- type OAuthResult
- type ParamValues
- type PasswordConfig
- type RouteConfig
- type Router
- func (r *Router) Connect(path string, handler Handler)
- func (r *Router) Delete(path string, handler Handler)
- func (r *Router) Get(path string, handler Handler)
- func (r *Router) GetMux() *mux.Router
- func (r *Router) Options(path string, handler Handler)
- func (r *Router) Patch(path string, handler Handler)
- func (r *Router) Post(path string, handler Handler)
- func (r *Router) Put(path string, handler Handler)
- func (r *Router) RouteGroup(prefix string, cb func(router *Router))
- func (r *Router) Trace(path string, handler Handler)
- func (r *Router) Use(name string)
- func (r *Router) UseStack(name string)
- type Session
- type SessionConfig
- type ViewConfig
- type ViewData
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidHash in returned by ComparePasswordAndHash if the provided // hash isn't in the expected format. ErrInvalidHash = errors.New("argon2id: hash is not in the correct format") // ErrIncompatibleVersion in returned by ComparePasswordAndHash if the // provided hash was created using a different version of Argon2. ErrIncompatibleVersion = errors.New("argon2id: incompatible version of argon2") )
var DefaultConfigs = &PasswordConfig{
Memory: 64 * 1024,
Iterations: 1,
Parallelism: 2,
SaltLength: 16,
KeyLength: 32,
}
Functions ¶
This section is empty.
Types ¶
type Application ¶
type Application struct { Configuration DefaultConfiguration MiddlewareRegistry *MiddlewareRegistry `json:"-"` Logger *logrus.Logger SessionStore *sessions.CookieStore Auth *Authentication Route *Router }
func New ¶
func New(conf DefaultConfiguration) *Application
New creates a new instance of Application
func (*Application) Assets ¶ added in v0.0.6
func (app *Application) Assets() []Asset
func (Application) JSON ¶ added in v0.0.15
func (app Application) JSON(ctx Context, data interface{}) error
func (Application) NewContext ¶ added in v0.0.4
func (app Application) NewContext(rc RouteConfig, w http.ResponseWriter, r *http.Request) Context
func (*Application) Serve ¶
func (app *Application) Serve()
type Asset ¶ added in v0.0.6
type Asset struct { Name string Extension FileExtension Path string }
type AssetsConfigs ¶ added in v0.0.6
type AssetsConfigs struct {
Path string `json:"path"`
}
type AuthUser ¶ added in v0.0.15
type AuthUser struct { Type AuthUserType Data interface{} }
type AuthUserType ¶ added in v0.0.15
type AuthUserType string
const ( GuestUserType AuthUserType = "guest" UserUserType AuthUserType = "user" )
type Authentication ¶ added in v0.0.15
type Authentication struct {
// contains filtered or unexported fields
}
func NewAuthentication ¶ added in v0.0.15
func NewAuthentication(app *Application) *Authentication
func (Authentication) CompareOAuthState ¶ added in v0.0.15
func (auth Authentication) CompareOAuthState(ctx Context, state string) error
func (Authentication) ComparePasswordAndHash ¶ added in v0.0.15
func (auth Authentication) ComparePasswordAndHash(password, hash string) (match bool, err error)
func (*Authentication) ExchangeAuthorisationCode ¶ added in v0.0.15
func (auth *Authentication) ExchangeAuthorisationCode(ctx Context, authorisationCode string) (OAuthResult, error)
func (Authentication) GeneratePasswordHash ¶ added in v0.0.15
func (auth Authentication) GeneratePasswordHash(c *PasswordConfig, password string) (string, error)
func (*Authentication) GetAuthUser ¶ added in v0.0.15
func (auth *Authentication) GetAuthUser(ctx Context) AuthUser
func (*Authentication) GetAuthorizationUri ¶ added in v0.0.15
func (auth *Authentication) GetAuthorizationUri(ctx Context) string
type AuthenticationConfig ¶ added in v0.0.15
type AuthenticationConfig struct { Provider AuthenticationProvider // The Configuration for the database provider Table string `json:"table"` // The Configuration for the oauth provider Endpoint string `json:"endpoint"` ClientID string `json:"clientId"` ClientSecret string `json:"clientSecret"` Scopes []string `json:"scopes"` RedirectPath string `json:"redirectPath"` }
type AuthenticationProvider ¶ added in v0.0.15
type AuthenticationProvider string
const ( OAuthAuthenticationProvider AuthenticationProvider = "oauth" DatabaseAuthenticationProvider AuthenticationProvider = "database" )
type Cookies ¶ added in v0.0.20
type Cookies struct {
// contains filtered or unexported fields
}
Cookies allows you to easily get cookies from the request, and set cookies on the response.
func (*Cookies) Delete ¶ added in v0.0.20
Delete sets a header that tells the browser to remove the cookie with the given name.
func (*Cookies) Get ¶ added in v0.0.20
Get returns the value of the cookie with the given name. Returns http.ErrNoCookie if there's no cookie with that name in the request.
func (*Cookies) Set ¶ added in v0.0.20
Set a cookie on the response, which will expire after the given duration.
func (*Cookies) SetWithExpirationTime ¶ added in v0.0.20
SetWithExpirationTime sets a cookie that will expire at a specific time. Note that the time is determined by the client's browser, so it might not expire at the expected time, for example if the client has changed the time on their computer.
func (*Cookies) SetWithPath ¶ added in v0.0.20
SetWithPath sets a cookie path on the server in which the cookie will be available on. If set to '/', the cookie will be available within the entire domain. If set to '/foo/', the cookie will only be available within the /foo/ directory and all sub-directories such as /foo/bar/ of domain.
type DatabaseConfig ¶
type DefaultConfiguration ¶
type DefaultConfiguration struct { App AppConfig `yaml:"app"` DB DatabaseConfig `yaml:"db"` View ViewConfig `yaml:"view"` Assets AssetsConfigs `yaml:"assets"` Session SessionConfig `yaml:"session"` Auth AuthenticationConfig `yaml:"auth"` }
func LoadConfigs ¶
func LoadConfigs(cfg *DefaultConfiguration) *DefaultConfiguration
type DefaultContext ¶ added in v0.0.4
func (*DefaultContext) Bind ¶ added in v0.0.20
func (d *DefaultContext) Bind(dst interface{}) error
func (*DefaultContext) Cookies ¶ added in v0.0.20
func (d *DefaultContext) Cookies() *Cookies
Cookies for the associated request and response.
func (*DefaultContext) Data ¶ added in v0.0.20
func (d *DefaultContext) Data() map[string]interface{}
func (*DefaultContext) Flash ¶ added in v0.0.20
func (d *DefaultContext) Flash() *Flash
Flash messages for the associated Request.
func (*DefaultContext) Param ¶ added in v0.0.20
func (d *DefaultContext) Param(key string) string
func (*DefaultContext) Params ¶ added in v0.0.4
func (d *DefaultContext) Params() ParamValues
func (*DefaultContext) Request ¶ added in v0.0.4
func (d *DefaultContext) Request() *http.Request
Request returns the original Request.
func (*DefaultContext) Response ¶ added in v0.0.4
func (d *DefaultContext) Response() http.ResponseWriter
Response returns the original Response for the request.
func (*DefaultContext) Session ¶ added in v0.0.20
func (d *DefaultContext) Session() *Session
func (*DefaultContext) Set ¶ added in v0.0.20
func (d *DefaultContext) Set(key string, value interface{})
func (*DefaultContext) Value ¶ added in v0.0.20
func (d *DefaultContext) Value(key interface{}) interface{}
Value that has previously stored on the context.
type ExchangeAuthorisationCodeRequest ¶ added in v0.0.15
type FileExtension ¶ added in v0.0.6
type FileExtension string
const ( Javascript FileExtension = "js" Stylesheet FileExtension = "css" )
type Flash ¶ added in v0.0.20
type Flash struct {
// contains filtered or unexported fields
}
Flash is a struct that helps with the operations over flash messages.
func (Flash) Add ¶ added in v0.0.20
Add adds a flash value for a flash key, if the key already has values the list for that value grows.
func (*Flash) Clear ¶ added in v0.0.20
func (f *Flash) Clear()
Clear removes all keys from the Flash.
type Handler ¶
type Handler func(Context, *Application) error
type JsonResponseBody ¶ added in v0.0.15
type JsonResponseBody struct {
Data interface{} `json:"data"`
}
type Middleware ¶ added in v0.0.15
type Middleware struct { Name string Handler MiddlewareFunc }
type MiddlewareFunc ¶ added in v0.0.4
type MiddlewareRegistry ¶ added in v0.0.15
type MiddlewareRegistry struct {
// contains filtered or unexported fields
}
func NewMiddlewareRegistry ¶ added in v0.0.15
func NewMiddlewareRegistry() *MiddlewareRegistry
func (*MiddlewareRegistry) Register ¶ added in v0.0.15
func (registry *MiddlewareRegistry) Register(name string, fn MiddlewareFunc)
func (*MiddlewareRegistry) RegisterStack ¶ added in v0.0.15
func (registry *MiddlewareRegistry) RegisterStack(name string, middlewares []string)
type MiddlewareStack ¶ added in v0.0.4
type MiddlewareStack struct {
// contains filtered or unexported fields
}
func (*MiddlewareStack) Use ¶ added in v0.0.4
func (ms *MiddlewareStack) Use(mw ...MiddlewareFunc)
type OAuthResult ¶ added in v0.0.15
type ParamValues ¶ added in v0.0.4
type PasswordConfig ¶ added in v0.0.15
type RouteConfig ¶ added in v0.0.4
type RouteConfig struct { Method string `json:"method"` Path string `json:"path"` HandlerName string `json:"handler"` ResourceName string `json:"resourceName,omitempty"` PathName string `json:"pathName"` Aliases []string `json:"aliases"` MuxRoute *mux.Route `json:"-"` Handler Handler `json:"-"` App *Application `json:"-"` Middlewares MiddlewareStack `json:"-"` }
func (RouteConfig) ServeHTTP ¶ added in v0.0.4
func (r RouteConfig) ServeHTTP(res http.ResponseWriter, req *http.Request)
type Router ¶ added in v0.0.15
type Router struct {
// contains filtered or unexported fields
}
func NewRouter ¶ added in v0.0.15
func NewRouter(app *Application) *Router
func (*Router) RouteGroup ¶ added in v0.0.15
type SessionConfig ¶ added in v0.0.15
type ViewConfig ¶ added in v0.0.4
type ViewConfig struct {
Path string `json:"path"`
}