handler

package
v0.0.0-...-4400219 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Errors Errors
}

type Errors

type Errors struct {
	Internal          string `yaml:"internal"`
	NotFound          string `yaml:"notFound"`
	MethodNotAllowed  string `yaml:"methodNotAllowed"`
	BodyLimitExceeded string `yaml:"bodyLimitExceeded"`
	BodyMalformed     string `yaml:"bodyMalformed"`
	BadBodyEncoding   string `yaml:"badBodyEncoding"`
	TooManyRequests   string `yaml:"tooManyRequests"`
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(cfg *Config) *Service

func (*Service) MethodNotAllowed

func (s *Service) MethodNotAllowed() http.HandlerFunc

func (*Service) NotFound

func (s *Service) NotFound() http.HandlerFunc

func (*Service) WithBodyLimit

func (s *Service) WithBodyLimit(bytes int64) func(http.Handler) http.Handler

func (*Service) WithRateLimit

func (s *Service) WithRateLimit(limiter ratelimit.Limiter) func(http.Handler) http.Handler

func (*Service) WithRequestID

func (s *Service) WithRequestID(h http.Handler) http.Handler

func (*Service) WithRequestTime

func (s *Service) WithRequestTime(h http.Handler) http.Handler

type UserConfig

type UserConfig struct {
	Errors             UserErrors
	Root               *Service
	DB                 postgres.UserService
	Mail               smtp.Service
	ConfirmationToken  jwt.Service[UserConfirmationToken]
	SessionToken       jwt.Service[UserSessionToken]
	SudoToken          jwt.Service[UserSessionToken]
	PasswordResetToken jwt.Service[UserPasswordResetToken]
	Password           argon2id.Service
	NameValidation     validation.Service[string]
	EmailValidation    validation.Service[string]
	PasswordValidation validation.Service[[]byte]
}

type UserConfirmationToken

type UserConfirmationToken struct {
	Email string `json:"email"`
}

type UserErrors

type UserErrors struct {
	BadName             string `yaml:"badName"`
	BadEmail            string `yaml:"badEmail"`
	BadPassword         string `yaml:"badPassword"`
	BadPasswordEncoding string `yaml:"badPasswordEncoding"`
	BadToken            string `yaml:"badToken"`
	BadSession          string `yaml:"badSession"`
	MissingSession      string `yaml:"missingSession"`
	InvalidCredentials  string `yaml:"invalidCredentials"`
	InvalidPassword     string `yaml:"invalidPassword"`
	NotFound            string `yaml:"notFound"`
	AlreadyExists       string `yaml:"alreadyExists"`
}

type UserPasswordResetToken

type UserPasswordResetToken struct {
	Id int64 `json:"id"`
}

type UserService

type UserService struct {
	// contains filtered or unexported fields
}

func NewUserService

func NewUserService(cfg *UserConfig) *UserService

func (*UserService) Create

func (s *UserService) Create(limiter ratelimit.Limiter) http.HandlerFunc

func (*UserService) CreateConfirmationToken

func (s *UserService) CreateConfirmationToken(mail UserTokenMail, limiter ratelimit.Limiter) http.HandlerFunc

func (*UserService) CreatePasswordResetToken

func (s *UserService) CreatePasswordResetToken(mail UserTokenMail, limiter ratelimit.Limiter) http.HandlerFunc

func (*UserService) CreateSessionToken

func (s *UserService) CreateSessionToken(ipLimiter ratelimit.Limiter, emailLimiter ratelimit.Limiter) http.HandlerFunc

func (*UserService) CreateSudoToken

func (s *UserService) CreateSudoToken(mail UserTokenMail, limiter ratelimit.Limiter) http.HandlerFunc

func (*UserService) Delete

func (s *UserService) Delete() http.HandlerFunc

func (*UserService) EditEmail

func (s *UserService) EditEmail() http.HandlerFunc

func (*UserService) EditName

func (s *UserService) EditName() http.HandlerFunc

func (*UserService) EditPassword

func (s *UserService) EditPassword() http.HandlerFunc

func (*UserService) Get

func (s *UserService) Get() http.HandlerFunc

func (*UserService) ResetPassword

func (s *UserService) ResetPassword(limiter ratelimit.Limiter) http.HandlerFunc

func (*UserService) WithSession

func (s *UserService) WithSession(svc jwt.Service[UserSessionToken], limiter ratelimit.Limiter) func(http.Handler) http.Handler

type UserSessionToken

type UserSessionToken struct {
	Id int64 `json:"id"`
}

type UserTokenMail

type UserTokenMail struct {
	Heading string `yaml:"heading"`
	Action  string `yaml:"action"`
}

Jump to

Keyboard shortcuts

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