web

package
v0.0.0-...-2cdd79a Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2025 License: MPL-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsAPI

func AsAPI(h Handler) gin.HandlerFunc

func AsHTML

func AsHTML(h Handler) gin.HandlerFunc

func LoadTmpl

func LoadTmpl() (err error)

func MustHaveUser

func MustHaveUser(c *gin.Context)

only used by 2fa

func MustRole

func MustRole(role ...actions.Role) func(Handler) Handler

func New

func New(db *gorm.DB) (task.Task, error)

func Wraps

func Wraps(g *gin.RouterGroup, as func(Handler) gin.HandlerFunc) routerSpec

Types

type Accessor

type Accessor[T any] interface {
	Get() T
	Defaults(v T) T
	NZ() bool
	IfZero(v T) T
	Set(T)
	Del()
}

type Context

type Context struct {
	*gin.Context
}

func (Context) DB

func (c Context) DB() *gorm.DB

func (Context) ReqID

func (c Context) ReqID() string

func (Context) Session

func (c Context) Session() Session

type ContextAccessor

type ContextAccessor[T any] struct {
	*gin.Context
	// contains filtered or unexported fields
}

func (ContextAccessor[T]) Defaults

func (a ContextAccessor[T]) Defaults(v T) T

func (ContextAccessor[T]) Del

func (a ContextAccessor[T]) Del()

func (ContextAccessor[T]) Get

func (a ContextAccessor[T]) Get() (ret T)

func (ContextAccessor[T]) IfZero

func (a ContextAccessor[T]) IfZero(v T) T

func (ContextAccessor[T]) NZ

func (a ContextAccessor[T]) NZ() bool

func (ContextAccessor[T]) Set

func (a ContextAccessor[T]) Set(v T)

type Getter

type Getter[T any] interface {
	Get() T
	Defaults(v T) T
	NZ() bool
	IfZero(v T) T
}

type Handler

type Handler func(Context) tmplspec

func MustAuth

func MustAuth(h Handler) Handler

type OTPKey

type OTPKey struct {
	*otp.Key
}

func (*OTPKey) GobDecode

func (o *OTPKey) GobDecode(data []byte) error

func (OTPKey) GobEncode

func (o OTPKey) GobEncode() ([]byte, error)

type Session

type Session struct {
	sessions.Session
}

func (Session) Authed

func (s Session) Authed() Accessor[bool]

func (Session) CurrentUser

func (s Session) CurrentUser() Accessor[*actions.User]

func (Session) LogCurrentUser

func (s Session) LogCurrentUser() extraLogInfo

func (Session) LoginNonce

func (s Session) LoginNonce() Accessor[string]

func (Session) NextMove

func (s Session) NextMove() Accessor[string]

func (Session) OTPErrorCount

func (s Session) OTPErrorCount() Accessor[int]

func (Session) OTPKey

func (s Session) OTPKey() Accessor[OTPKey]

func (Session) OauthState

func (s Session) OauthState() Accessor[string]

type SessionAccessor

type SessionAccessor[T any] struct {
	sessions.Session
	// contains filtered or unexported fields
}

func (SessionAccessor[T]) Defaults

func (a SessionAccessor[T]) Defaults(v T) T

func (SessionAccessor[T]) Del

func (a SessionAccessor[T]) Del()

func (SessionAccessor[T]) Get

func (a SessionAccessor[T]) Get() (ret T)

func (SessionAccessor[T]) IfZero

func (a SessionAccessor[T]) IfZero(v T) T

func (SessionAccessor[T]) NZ

func (a SessionAccessor[T]) NZ() bool

func (SessionAccessor[T]) Set

func (a SessionAccessor[T]) Set(v T)

Jump to

Keyboard shortcuts

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