middleware

package
v1.15.5 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: MIT Imports: 12 Imported by: 11

Documentation

Index

Constants

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

flashes enumerates all the flash types

Variables

View Source
var (
	// FlashNow FIXME:
	FlashNow bool
)

Functions

func AssignForm

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

AssignForm assign form values back to the template data.

func DeleteCSRFCookie

func DeleteCSRFCookie(resp http.ResponseWriter)

DeleteCSRFCookie convenience function to delete SessionConfigPath cookies consistently

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 ot previous state.

func DeleteRedirectToCookie

func DeleteRedirectToCookie(resp http.ResponseWriter)

DeleteRedirectToCookie convenience function to delete most cookies consistently

func DeleteSesionConfigPathCookie

func DeleteSesionConfigPathCookie(resp http.ResponseWriter, name string)

DeleteSesionConfigPathCookie convenience function to delete SessionConfigPath cookies consistently

func Domain

func Domain(domain string) func(*http.Cookie)

Domain sets the domain for a provided cookie

func Expires

func Expires(expires time.Time) func(*http.Cookie)

Expires sets the expires and rawexpires for a provided cookie

func GetCookie

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

GetCookie returns given cookie value from request header.

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 GetSize

func GetSize(field reflect.StructField) string

GetSize get size int form tag

func HTTPOnly

func HTTPOnly(httpOnly bool) func(*http.Cookie)

HTTPOnly sets the HttpOnly setting for a provided cookie

func IsAPIPath

func IsAPIPath(req *http.Request) bool

IsAPIPath returns true if the specified URL is an API path

func IsInternalPath

func IsInternalPath(req *http.Request) bool

IsInternalPath returns true if the specified URL is an internal API path

func Locale

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

Locale handle locale

func MaxAge

func MaxAge(maxAge int) func(*http.Cookie)

MaxAge sets the maximum age for a provided cookie

func NewCookie

func NewCookie(name, value string, maxAge int) *http.Cookie

NewCookie creates a cookie

func Path

func Path(path string) func(*http.Cookie)

Path sets the path for a provided cookie

func SameSite

func SameSite(sameSite http.SameSite) func(*http.Cookie)

SameSite sets the SameSite for a provided cookie

func Secure

func Secure(secure bool) func(*http.Cookie)

Secure sets the secure setting for a provided cookie

func SetCookie

func SetCookie(resp http.ResponseWriter, name string, value string, others ...interface{})

SetCookie set the cookies TODO: Copied from gitea.com/macaron/macaron and should be improved after macaron removed.

func SetLocaleCookie

func SetLocaleCookie(resp http.ResponseWriter, lang string, expiry 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 Validate

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

Validate validate TODO:

Types

type DataStore

type DataStore interface {
	GetData() map[string]interface{}
}

DataStore represents a data store

type Flash

type Flash struct {
	DataStore
	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