middleware

package
v0.19.4 Latest Latest
Warning

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

Go to latest
Published: May 24, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SuccessFlash = "SuccessMsg"
	ErrorFlash   = "ErrorMsg"
	WarnFlash    = "WarningMsg"
	InfoFlash    = "InfoMsg"
)

flashes enumerates all the flash types

View Source
const ContextDataKeySignedUser = "SignedUser"

Variables

View Source
var FlashNow bool

FlashNow FIXME:

Functions

func AssignForm

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

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

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

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]interface{}, f Form, l translation.Locale) binding.Errors

Validate validate TODO:

func WithContextData

func WithContextData(c context.Context) context.Context

Types

type ContextData

type ContextData map[string]any

func CommonTemplateContextData

func CommonTemplateContextData() ContextData

func GetContextData

func GetContextData(c context.Context) ContextData

func (ContextData) GetData

func (ds ContextData) GetData() map[string]any

func (ContextData) MergeFrom

func (ds ContextData) MergeFrom(other ContextData) ContextData

type ContextDataStore

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