ctx

package
v1.0.64 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserIDKey           = "user_id"
	OriginalUserIDKey   = "original_user_id"
	UserRoleKey         = "user_role"
	OriginalUserRoleKey = "original_user_role"
	DestinationKey      = "destination"
	FlashCookiePrefix   = "flash"
)
View Source
const CandidateRecordKey = contextKey("publication")
View Source
const DatasetKey = contextKey("dataset")
View Source
const PublicationKey = contextKey("publication")

Variables

This section is empty.

Functions

func GetCandidateRecord added in v1.0.59

func GetCandidateRecord(r *http.Request) *models.CandidateRecord

func GetDataset added in v1.0.56

func GetDataset(r *http.Request) *models.Dataset

func GetPublication added in v1.0.56

func GetPublication(r *http.Request) *models.Publication

func RequireCurator added in v1.0.56

func RequireCurator(next http.Handler) http.Handler

func RequireEditCandidateRecord added in v1.0.59

func RequireEditCandidateRecord(repo *repositories.Repo) func(http.Handler) http.Handler

func RequireEditDataset added in v1.0.56

func RequireEditDataset(repo *repositories.Repo) func(http.Handler) http.Handler

func RequireEditPublication added in v1.0.56

func RequireEditPublication(repo *repositories.Repo) func(http.Handler) http.Handler

func RequireUser

func RequireUser(next http.Handler) http.Handler

func RequireViewCandidateRecord added in v1.0.59

func RequireViewCandidateRecord(repo *repositories.Repo) func(http.Handler) http.Handler

func RequireViewDataset added in v1.0.56

func RequireViewDataset(repo *repositories.Repo) func(http.Handler) http.Handler

func RequireViewPublication added in v1.0.56

func RequireViewPublication(repo *repositories.Repo) func(http.Handler) http.Handler

func Set

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

func SetCandidateRecord added in v1.0.59

func SetCandidateRecord(repo *repositories.Repo) func(http.Handler) http.Handler

func SetDataset added in v1.0.56

func SetDataset(repo *repositories.Repo) func(http.Handler) http.Handler

func SetNav

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

func SetPublication added in v1.0.56

func SetPublication(repo *repositories.Repo) func(http.Handler) http.Handler

func SetSubNav added in v1.0.56

func SetSubNav(subNav string) func(http.Handler) http.Handler

Types

type Config

type Config struct {
	*backends.Services
	Logger              *slog.Logger
	Router              *ich.Mux
	Assets              map[string]string
	MaxFileSize         int
	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           *slog.Logger
	Loc           *gotext.Locale
	User          *models.Person
	UserRole      string
	OriginalUser  *models.Person
	ProxiedPerson *models.Person
	Flash         []flash.Flash
	CSRFToken     string
	CSPNonce      string
	Nav           string
	SubNav        string
	CurrentURL    *url.URL
	// 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) FlagCandidateRecords added in v1.0.56

func (c *Ctx) FlagCandidateRecords() bool

TODO temporary flag implementation

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 ...any) *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 ...any) *url.URL

Jump to

Keyboard shortcuts

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