contx

package
v1.0.1-0...-497af47 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2020 License: CC-BY-SA-4.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssignForm

func AssignForm(form interface{}, data map[string]interface{})

AssignForm assign form values back to the template data.

func Contexter

func Contexter() macaron.Handler

Contexter middleware

func GetSize

func GetSize(field reflect.StructField) string

GetSize get size validation

func I18n

func I18n(key string) string

I18n view func

func Validate

func Validate(errs binding.Errors, data map[string]interface{}, f Form, l macaron.Locale) binding.Errors

Validate form

Types

type Context

type Context struct {
	*macaron.Context

	Session session.Store
	Flash   *session.Flash
	Cache   cache.Cache
	Toolbox toolbox.Toolbox
	// contains filtered or unexported fields
}

Context representation

func GetContext

func GetContext() *Context

GetContext Get system context

func (*Context) HTML

func (ctx *Context) HTML(status int, name string)

HTML render using jade

func (*Context) HasError

func (ctx *Context) HasError() bool

HasError return true if request has errors

func (*Context) JSONWithoutEscape

func (ctx *Context) JSONWithoutEscape(status int, obj interface{})

JSONWithoutEscape render json without escape

func (*Context) NativeHTML

func (ctx *Context) NativeHTML(status int, name string)

NativeHTML render using go engine

func (*Context) NativeRenderWithErr

func (ctx *Context) NativeRenderWithErr(msg string, tpl string, userForm interface{})

NativeRenderWithErr render view and add error message using Go engine

func (*Context) RenderWithErr

func (ctx *Context) RenderWithErr(msg string, tpl string, userForm interface{})

RenderWithErr render view and add error message using jade

type Form

type Form interface {
	binding.Validator
}

Form representation

type Login

type Login struct {
	Username string `binding:"Required"`
	Password string `binding:"Required"`
}

Login form representation

func (*Login) Validate

func (f *Login) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors

Validate Login form

Jump to

Keyboard shortcuts

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