Documentation ΒΆ
Index ΒΆ
- func GetUser(req *http.Request) session.User
- func ParseForm(req *http.Request, dst interface{})
- func PrintLogo(logoFile string)
- func Redirect(to string) func() http.HandlerFunc
- type Builder
- type HtmlRenderer
- func (r HtmlRenderer) CreateView(req *http.Request, tmpl *template.Template, model interface{}) View
- func (r HtmlRenderer) Parse(patterns ...string) *template.Template
- func (r HtmlRenderer) ParseAlone(file string) *template.Template
- func (r HtmlRenderer) ParsePartial(defName string, patterns ...string) *template.Template
- func (r HtmlRenderer) ParseWithShared(patterns ...string) *template.Template
- 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) http.HandlerFunc
- func (injector Injector) ShowAvailableBuilders()
- type Middleware
- type Mux
- func (mux *Mux) Add(builder Builder)
- func (mux *Mux) Any(pattern string, builder Builder, middlewares ...Middleware)
- func (mux *Mux) Delete(pattern string, builder Builder, middlewares ...Middleware)
- func (mux *Mux) FileServer(pattern, root string)
- func (mux *Mux) FileServerStatic(path string)
- func (mux *Mux) Get(pattern string, builder Builder, middlewares ...Middleware)
- func (mux *Mux) Head(pattern string, builder Builder, middlewares ...Middleware)
- func (mux Mux) ListenAndServe(address string)
- func (mux *Mux) Mount(pattern string, inner *Mux)
- func (mux *Mux) Options(pattern string, builder Builder, middlewares ...Middleware)
- func (mux *Mux) Patch(pattern string, builder Builder, middlewares ...Middleware)
- func (mux *Mux) PopulateStruct(s interface{})
- func (mux *Mux) Post(pattern string, builder Builder, middlewares ...Middleware)
- func (mux *Mux) Put(pattern string, builder Builder, middlewares ...Middleware)
- func (mux *Mux) ShowAvailableBuilders()
- func (mux *Mux) Trace(pattern string, builder Builder, middlewares ...Middleware)
- func (mux *Mux) Use(middleware Middleware)
- type Render
- type View
- 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
func PrintLogo ΒΆ
func PrintLogo(logoFile string)
PrintLogo takes a file path and prints your fancy ascii logo. It will fail if your file is not found.
func Redirect ΒΆ
func Redirect(to string) func() http.HandlerFunc
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 HtmlRenderer ΒΆ
type HtmlRenderer struct {
// contains filtered or unexported fields
}
func NewHtmlRenderer ΒΆ
func NewHtmlRenderer(files embed.FS, csrf csrf.Csrf, localizer localizer.LocalizerStore) HtmlRenderer
func NewHtmlRendererWithExtraFuncs ΒΆ
func NewHtmlRendererWithExtraFuncs(files embed.FS, csrf csrf.Csrf, localizer localizer.LocalizerStore, extra template.FuncMap) HtmlRenderer
func (HtmlRenderer) CreateView ΒΆ
func (HtmlRenderer) ParseAlone ΒΆ
func (r HtmlRenderer) ParseAlone(file string) *template.Template
func (HtmlRenderer) ParsePartial ΒΆ
func (r HtmlRenderer) ParsePartial(defName string, patterns ...string) *template.Template
func (HtmlRenderer) ParseWithShared ΒΆ
func (r HtmlRenderer) ParseWithShared(patterns ...string) *template.Template
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 ΒΆ
func (injector Injector) ResolveHandler(builder Builder) http.HandlerFunc
ResolveHandler created by a builder
func (Injector) ShowAvailableBuilders ΒΆ
func (injector Injector) ShowAvailableBuilders()
ShowAvailableBuilders prints all registered builders.
type Middleware ΒΆ
type Middleware func(http.HandlerFunc) http.HandlerFunc
type Mux ΒΆ
type Mux struct {
// contains filtered or unexported fields
}
func NewMuxEmpty ΒΆ
func NewMuxEmpty() Mux
func NewMuxFrom ΒΆ
func (*Mux) Delete ΒΆ
func (mux *Mux) Delete(pattern string, builder Builder, middlewares ...Middleware)
func (*Mux) FileServer ΒΆ
FileServer creates using a router, a url path and a file path a file server.
func (*Mux) FileServerStatic ΒΆ
FileServerStatic creates a file server with your desired path a file server that serves files in ./static folder.
func (*Mux) Head ΒΆ
func (mux *Mux) Head(pattern string, builder Builder, middlewares ...Middleware)
func (Mux) ListenAndServe ΒΆ
func (*Mux) Options ΒΆ
func (mux *Mux) Options(pattern string, builder Builder, middlewares ...Middleware)
func (*Mux) Patch ΒΆ
func (mux *Mux) Patch(pattern string, builder Builder, middlewares ...Middleware)
func (*Mux) PopulateStruct ΒΆ
func (mux *Mux) PopulateStruct(s interface{})
func (*Mux) Post ΒΆ
func (mux *Mux) Post(pattern string, builder Builder, middlewares ...Middleware)
func (*Mux) ShowAvailableBuilders ΒΆ
func (mux *Mux) ShowAvailableBuilders()
func (*Mux) Trace ΒΆ
func (mux *Mux) Trace(pattern string, builder Builder, middlewares ...Middleware)
func (*Mux) Use ΒΆ
func (mux *Mux) Use(middleware Middleware)
type Render ΒΆ
type Render func(data interface{}, err error)
func NewJsonRenderer ΒΆ
func NewJsonRenderer(w http.ResponseWriter, req *http.Request) Render
type View ΒΆ
type View struct {
// contains filtered or unexported fields
}