ctx

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RememberCookie    = "deliver.remember"
	FlashCookiePrefix = "deliver.flash."
)

TODO set __Host- cookie prefix in production

Variables

This section is empty.

Functions

func CanEditFile

func CanEditFile(next http.Handler) http.Handler

func CanEditFolder

func CanEditFolder(next http.Handler) http.Handler

func CanViewSpace

func CanViewSpace(next http.Handler) http.Handler

func GetFile

func GetFile(r *http.Request) *models.File

func GetFolder

func GetFolder(r *http.Request) *models.Folder

func GetSpace

func GetSpace(r *http.Request) *models.Space

func RequireAdmin

func RequireAdmin(next http.Handler) http.Handler

func RequireUser

func RequireUser(next http.Handler) http.Handler

func Set

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

func SetFile

func SetFile(filesRepo repositories.FilesRepo) func(http.Handler) http.Handler

func SetFolder

func SetFolder(foldersRepo repositories.FoldersRepo) func(http.Handler) http.Handler

func SetSpace

func SetSpace(spacesRepo repositories.SpacesRepo) func(http.Handler) http.Handler

Types

type Config

type Config struct {
	*crypt.Crypt
	Env           string
	Repo          *repositories.Repo
	Storage       objectstores.Store
	MaxFileSize   int64
	Router        *ich.Mux
	ErrorHandlers map[int]http.HandlerFunc
	Permissions   *models.Permissions
	Assets        mix.Manifest
	Hub           *catbird.Hub
	Timezone      *time.Location
	CSRFName      string
}

type Ctx

type Ctx struct {
	Config

	Log       *zap.SugaredLogger
	CSRFToken string
	CSPNonce  string
	User      *models.User
	Flash     []Flash
	// 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) Path added in v1.1.4

func (c *Ctx) Path(name string, params ...any) *url.URL

func (*Ctx) PersistFlash

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

func (*Ctx) URL added in v1.1.4

func (c *Ctx) URL(name string, params ...any) *url.URL

func (*Ctx) WebSocketPath

func (c *Ctx) WebSocketPath(topics ...string) string

type Flash

type Flash struct {
	Type         string
	Title        string
	Body         string
	DismissAfter time.Duration
}

Jump to

Keyboard shortcuts

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