middleware

package
v1.21.2 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: MIT Imports: 13 Imported by: 11

Documentation

Index

Constants

View Source
const ContextDataKeySignedUser = "SignedUser"

Variables

This section is empty.

Functions

func AssignForm

func AssignForm(form any, data map[string]any)

AssignForm assign form values back to the template data.

func DeleteLocaleCookie

func DeleteLocaleCookie(resp http.ResponseWriter)

DeleteLocaleCookie convenience function to delete the locale cookie consistently Setting the lang cookie will trigger the middleware to reset the language to previous state.

func DeleteRedirectToCookie

func DeleteRedirectToCookie(resp http.ResponseWriter)

DeleteRedirectToCookie convenience function to delete most cookies consistently

func GetInclude

func GetInclude(field reflect.StructField) string

GetInclude get include in form tag

func GetMaxSize

func GetMaxSize(field reflect.StructField) string

GetMaxSize get max size in form tag

func GetMinSize

func GetMinSize(field reflect.StructField) string

GetMinSize get minimal size in form tag

func GetSiteCookie added in v1.20.0

func GetSiteCookie(req *http.Request, name string) string

GetSiteCookie returns given cookie value from request header.

func GetSize

func GetSize(field reflect.StructField) string

GetSize get size int form tag

func IsAPIPath

func IsAPIPath(req *http.Request) bool

IsAPIPath returns true if the specified URL is an API path

func Locale

func Locale(resp http.ResponseWriter, req *http.Request) translation.Locale

Locale handle locale

func SetLocaleCookie

func SetLocaleCookie(resp http.ResponseWriter, lang string, maxAge int)

SetLocaleCookie convenience function to set the locale cookie consistently

func SetRedirectToCookie

func SetRedirectToCookie(resp http.ResponseWriter, value string)

SetRedirectToCookie convenience function to set the RedirectTo cookie consistently

func SetSiteCookie added in v1.20.0

func SetSiteCookie(resp http.ResponseWriter, name, value string, maxAge int)

SetSiteCookie returns given cookie value from request header.

func Validate

func Validate(errs binding.Errors, data map[string]any, f Form, l translation.Locale) binding.Errors

Validate validate TODO:

func WithContextData added in v1.20.0

func WithContextData(c context.Context) context.Context

Types

type ContextData added in v1.20.0

type ContextData map[string]any

func CommonTemplateContextData added in v1.20.0

func CommonTemplateContextData() ContextData

func GetContextData added in v1.20.0

func GetContextData(c context.Context) ContextData

func (ContextData) GetData added in v1.20.0

func (ds ContextData) GetData() ContextData

func (ContextData) MergeFrom added in v1.20.0

func (ds ContextData) MergeFrom(other ContextData) ContextData

type ContextDataStore added in v1.20.0

type ContextDataStore interface {
	GetData() ContextData
}

ContextDataStore represents a data store

type Flash

type Flash struct {
	DataStore ContextDataStore
	url.Values
	ErrorMsg, WarningMsg, InfoMsg, SuccessMsg string
}

Flash represents a one time data transfer between two requests.

func (*Flash) Error

func (f *Flash) Error(msg string, current ...bool)

Error sets error message

func (*Flash) Info

func (f *Flash) Info(msg string, current ...bool)

Info sets info message

func (*Flash) Success

func (f *Flash) Success(msg string, current ...bool)

Success sets success message

func (*Flash) Warning

func (f *Flash) Warning(msg string, current ...bool)

Warning sets warning message

type Form

type Form interface {
	binding.Validator
}

Form form binding interface

Jump to

Keyboard shortcuts

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