appcontext

package
v0.1536.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package appcontext provides functionality to pass data in contexts through the lifetime of a web request.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithData added in v0.1339.0

func ContextWithData(ctx context.Context, appData Data) context.Context

func ContextWithSession added in v0.1339.0

func ContextWithSession(ctx context.Context, data *Session) context.Context

Types

type Data added in v0.1339.0

type Data struct {
	Page              string
	Path              string
	Query             url.Values
	Localizer         Localizer
	Lang              localize.Lang
	CookieConsentSet  bool
	CanGoBack         bool
	SessionID         string
	LpaID             string
	CsrfToken         string
	ActorType         actor.Type
	AttorneyUID       actoruid.UID
	LoginSessionEmail string
	SupporterData     *SupporterData
}

func DataFromContext added in v0.1339.0

func DataFromContext(ctx context.Context) Data

func (Data) EncodeQuery added in v0.1339.0

func (d Data) EncodeQuery() string

func (Data) IsAdmin added in v0.1339.0

func (d Data) IsAdmin() bool

func (Data) IsAttorneyType added in v0.1339.0

func (d Data) IsAttorneyType() bool

func (Data) IsCertificateProvider added in v0.1339.0

func (d Data) IsCertificateProvider() bool

func (Data) IsDonor added in v0.1339.0

func (d Data) IsDonor() bool

func (Data) IsReplacementAttorney added in v0.1339.0

func (d Data) IsReplacementAttorney() bool

func (Data) IsTrustCorporation added in v0.1339.0

func (d Data) IsTrustCorporation() bool

func (Data) Redirect added in v0.1339.0

func (d Data) Redirect(w http.ResponseWriter, r *http.Request, url string) error

type Localizer added in v0.1339.0

type Localizer interface {
	Concat(list []string, joiner string) string
	Count(messageID string, count int) string
	Format(messageID string, data map[string]interface{}) string
	FormatCount(messageID string, count int, data map[string]any) string
	FormatDate(t date.TimeOrDate) string
	FormatTime(t time.Time) string
	FormatDateTime(t time.Time) string
	Possessive(s string) string
	SetShowTranslationKeys(s bool)
	ShowTranslationKeys() bool
	T(messageID string) string
}

type Session added in v0.1339.0

type Session struct {
	SessionID string
	LpaID     string

	// if a supporter
	Email          string
	OrganisationID string
}

func SessionFromContext added in v0.1339.0

func SessionFromContext(ctx context.Context) (*Session, error)

type SessionMissingError

type SessionMissingError struct{}

func (SessionMissingError) Error

func (s SessionMissingError) Error() string

type SupporterData added in v0.1339.0

type SupporterData struct {
	LpaType              lpadata.LpaType
	DonorFullName        string
	OrganisationName     string
	IsManageOrganisation bool
	Permission           supporterdata.Permission
	LoggedInSupporterID  string
}

Jump to

Keyboard shortcuts

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