ctx

package
v1.0.55 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserIDKey           = "user_id"
	OriginalUserIDKey   = "original_user_id"
	UserRoleKey         = "user_role"
	OriginalUserRoleKey = "original_user_role"
	FlashCookiePrefix   = "flash"
)

Variables

This section is empty.

Functions

func RequireUser

func RequireUser(next http.Handler) http.Handler

func Set

func Set(config Config) func(http.Handler) http.Handler

func SetNav

func SetNav(nav string) func(http.Handler) http.Handler

Types

type Config

type Config struct {
	*backends.Services
	Router              *ich.Mux
	Assets              mix.Manifest
	Timezone            *time.Location
	Loc                 *gotext.Locale
	Env                 string
	StatusErrorHandlers map[int]http.HandlerFunc
	ErrorHandlers       map[error]http.HandlerFunc
	SessionName         string
	SessionStore        sessions.Store
	BaseURL             *url.URL
	FrontendURL         string
	CSRFName            string
}

type Ctx

type Ctx struct {
	Config

	Log          *zap.SugaredLogger
	Loc          *gotext.Locale
	User         *models.Person
	UserRole     string
	OriginalUser *models.Person
	Flash        []flash.Flash
	CSRFToken    string
	CSPNonce     string
	Nav          string
	// contains filtered or unexported fields
}

func Get

func Get(r *http.Request) *Ctx

func (*Ctx) AssetPath

func (c *Ctx) AssetPath(asset string) string

func (*Ctx) HandleError

func (c *Ctx) HandleError(w http.ResponseWriter, r *http.Request, err error)

func (*Ctx) PathTo

func (c *Ctx) PathTo(name string, pairs ...string) *url.URL

func (*Ctx) PersistFlash

func (c *Ctx) PersistFlash(w http.ResponseWriter, f flash.Flash)

func (*Ctx) URLTo

func (c *Ctx) URLTo(name string, pairs ...string) *url.URL

Jump to

Keyboard shortcuts

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