middleware

package
v0.0.0-...-495e01f Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

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

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 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() ContextData

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