Documentation ΒΆ
Index ΒΆ
- func ParseForm(req *http.Request, dst interface{})
- func PrintLogo(logoFile string)
- type Builder
- type Context
- func (ctx *Context) GetUser() session.User
- func (ctx *Context) Json(status int, data interface{})
- func (ctx *Context) Redirect(to string) func() http.HandlerFunc
- func (ctx *Context) Render(status int, parsed string, vm interface{})
- func (ctx *Context) RenderWithErrors(status int, parsed string, vm interface{}, formErrors map[string]string)
- type CorsConfig
- type Handler
- type Injector
- func (injector Injector) Add(builder Builder)
- func (injector Injector) CallBuilder(builder Builder) interface{}
- func (injector Injector) Get(name interface{}) interface{}
- func (injector Injector) GetByType(name reflect.Type) interface{}
- func (injector Injector) PopulateStruct(userStruct interface{})
- func (injector Injector) ResolveHandler(builder Builder) Handler
- func (injector Injector) ShowAvailableBuilders()
- type Middleware
- type PhxConfig
- type Router
- func (r *Router) Add(builder Builder)
- func (r *Router) AddDefaultTemplateFunctions()
- func (r *Router) Bootstrap(inj *Injector)
- func (r *Router) Delete(pattern string, builder Builder, middlewares ...Middleware)
- func (r *Router) Get(pattern string, builder Builder, middlewares ...Middleware)
- func (r *Router) Handle(method, pattern string, builder Builder, middlewares ...Middleware)
- func (r *Router) Head(pattern string, builder Builder, middlewares ...Middleware)
- func (r *Router) Options(pattern string, builder Builder, middlewares ...Middleware)
- func (r *Router) Parse(name string, patterns ...string)
- func (r *Router) ParsePartial(name string, patterns ...string)
- func (r *Router) Patch(pattern string, builder Builder, middlewares ...Middleware)
- func (r *Router) PopulateStruct(s interface{})
- func (r *Router) Post(pattern string, builder Builder, middlewares ...Middleware)
- func (r *Router) Put(pattern string, builder Builder, middlewares ...Middleware)
- func (r Router) Run(address string)
- func (r *Router) ShowAvailableBuilders()
- func (r *Router) Trace(pattern string, builder Builder, middlewares ...Middleware)
- func (r *Router) Use(middleware Middleware)
- type SessionAuth
- type ViewModel
Constants ΒΆ
This section is empty.
Variables ΒΆ
This section is empty.
Functions ΒΆ
func ParseForm ΒΆ
ParseForm parses req.Form and then serializes the form data to the dst struct using reflection. The form names should match to the 'html' tag or, if its not setted, to the field name. ParseForm only supports serializing data to one-depth structs. Example, using this struct as target:
type MyStruct struct { A bool, B int `html:"pagination.currentPage"` }
And having this serialized form:
"A=false&pagination.currentPage=2"
Calling ParseForm like this (NOTE THAT A POINTER TO THE STRUCT IS BEING PASSED):
var s MyStruct phx.ParseForm(req, &s)
It will result to this fullfilled struct:
{ A = false, B: 2 }
The supported field types are: int, int8, int16, int32, int64, float32, float64, bool and string
Types ΒΆ
type Builder ΒΆ
type Builder interface{}
Builder is a function that expects anything and retuns the type that builds. The type cant be func() interface{} cause some errors appears in runtime. So it's represented as an interface.
type Context ΒΆ added in v0.0.15
type Context struct { Req *http.Request Res http.ResponseWriter // contains filtered or unexported fields }
func (*Context) Redirect ΒΆ added in v0.0.15
func (ctx *Context) Redirect(to string) func() http.HandlerFunc
type CorsConfig ΒΆ added in v0.0.15
type Injector ΒΆ
type Injector struct {
// contains filtered or unexported fields
}
Injector is an automated dependency injector inspired in Sping's DI. It will detect which builder to call using its return type. If the builder haver params, it will fullfill that params calling other builders that provides its types.
func (Injector) CallBuilder ΒΆ
CallBuilder injecting all parameters with provided builders. If some parameter type cannot be found, it will panic
func (Injector) Get ΒΆ
func (injector Injector) Get(name interface{}) interface{}
Get returns a builded dependency
func (Injector) PopulateStruct ΒΆ
func (injector Injector) PopulateStruct(userStruct interface{})
PopulateStruct fills a struct with the implementations that the injector can create. Make sure you pass a reference and not a value
func (Injector) ResolveHandler ΒΆ
ResolveHandler created by a builder
func (Injector) ShowAvailableBuilders ΒΆ
func (injector Injector) ShowAvailableBuilders()
ShowAvailableBuilders prints all registered builders.
type Middleware ΒΆ
type PhxConfig ΒΆ added in v0.0.15
type PhxConfig struct { CsrfExpiration time.Duration Localizer *localizer.LocalizerStore Cors CorsConfig EnableCors bool StaticPath string EnableStatic bool EnableCsrf bool }
type Router ΒΆ added in v0.0.15
type Router struct {
// contains filtered or unexported fields
}
func NewRouterFromOther ΒΆ added in v0.0.15
func NewRouterWithConfig ΒΆ added in v0.0.15
func (*Router) AddDefaultTemplateFunctions ΒΆ added in v0.0.15
func (r *Router) AddDefaultTemplateFunctions()
func (*Router) Delete ΒΆ added in v0.0.15
func (r *Router) Delete(pattern string, builder Builder, middlewares ...Middleware)
func (*Router) Get ΒΆ added in v0.0.15
func (r *Router) Get(pattern string, builder Builder, middlewares ...Middleware)
func (*Router) Handle ΒΆ added in v0.0.15
func (r *Router) Handle(method, pattern string, builder Builder, middlewares ...Middleware)
func (*Router) Head ΒΆ added in v0.0.15
func (r *Router) Head(pattern string, builder Builder, middlewares ...Middleware)
func (*Router) Options ΒΆ added in v0.0.15
func (r *Router) Options(pattern string, builder Builder, middlewares ...Middleware)
func (*Router) ParsePartial ΒΆ added in v0.0.15
func (*Router) Patch ΒΆ added in v0.0.15
func (r *Router) Patch(pattern string, builder Builder, middlewares ...Middleware)
func (*Router) PopulateStruct ΒΆ added in v0.0.15
func (r *Router) PopulateStruct(s interface{})
func (*Router) Post ΒΆ added in v0.0.15
func (r *Router) Post(pattern string, builder Builder, middlewares ...Middleware)
func (*Router) Put ΒΆ added in v0.0.15
func (r *Router) Put(pattern string, builder Builder, middlewares ...Middleware)
func (*Router) ShowAvailableBuilders ΒΆ added in v0.0.15
func (r *Router) ShowAvailableBuilders()
func (*Router) Trace ΒΆ added in v0.0.15
func (r *Router) Trace(pattern string, builder Builder, middlewares ...Middleware)
func (*Router) Use ΒΆ added in v0.0.15
func (r *Router) Use(middleware Middleware)
type SessionAuth ΒΆ added in v0.0.15
type SessionAuth struct {
// contains filtered or unexported fields
}
func NewSessionAuth ΒΆ added in v0.0.15
func NewSessionAuth(sessionManager *session.Manager) SessionAuth
func NewSessionAuthWithRedirection ΒΆ added in v0.0.15
func NewSessionAuthWithRedirection(sessionManager *session.Manager, redirectURL string) SessionAuth
func (SessionAuth) Admin ΒΆ added in v0.0.15
func (authMiddle SessionAuth) Admin(next Handler) Handler
func (SessionAuth) Authorize ΒΆ added in v0.0.15
func (authMiddle SessionAuth) Authorize(next Handler) Handler
func (SessionAuth) AuthorizeRoles ΒΆ added in v0.0.15
func (authMiddle SessionAuth) AuthorizeRoles(roles []core.Role, next Handler) Handler