types

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContextKeyUser         contextKey = "user"
	ContextKeySession      contextKey = "session"
	ContextKeyOrganization contextKey = "organization"
)

Variables

View Source
var (
	// User errors
	ErrUserNotFound       = errors.New("user not found")
	ErrUserAlreadyExists  = errors.New("user already exists")
	ErrEmailAlreadyExists = errors.New("email already exists")
	ErrInvalidCredentials = errors.New("invalid credentials")

	// Session errors
	ErrSessionNotFound = errors.New("session not found")
	ErrSessionExpired  = errors.New("session expired")
	ErrInvalidSession  = errors.New("invalid session")

	// Auth errors
	ErrUnauthorized     = errors.New("unauthorized")
	ErrForbidden        = errors.New("forbidden")
	ErrEmailNotVerified = errors.New("email not verified")

	// Organization errors
	ErrOrganizationNotFound  = errors.New("organization not found")
	ErrNotOrganizationMember = errors.New("not an organization member")

	// Generic errors
	ErrInvalidInput  = errors.New("invalid input")
	ErrInternalError = errors.New("internal error")
)

Common errors

Functions

func SetAuthContext

func SetAuthContext(ctx context.Context, authCtx *AuthContext) context.Context

SetAuthContext sets auth context in context

Types

type AuthContext

type AuthContext struct {
	UserID         string
	SessionID      string
	OrganizationID string
	Roles          []string
}

AuthContext contains authentication context

func GetAuthContext

func GetAuthContext(ctx context.Context) (*AuthContext, bool)

GetAuthContext retrieves auth context from context

type PaginatedResult

type PaginatedResult struct {
	Data       interface{}
	Total      int
	Page       int
	PageSize   int
	TotalPages int
}

PaginatedResult represents a paginated result

type PaginationOptions

type PaginationOptions struct {
	Page     int
	PageSize int
	OrderBy  string
	OrderDir string // "asc" or "desc"
}

Pagination options

func DefaultPagination

func DefaultPagination() PaginationOptions

DefaultPagination returns default pagination options

type ValidationError

type ValidationError struct {
	Field   string
	Message string
}

ValidationError represents a validation error

func NewValidationError

func NewValidationError(field, message string) *ValidationError

NewValidationError creates a new validation error

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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