Documentation
¶
Index ¶
- Constants
- Variables
- func Migrate(db *sql.DB, dir string) error
- func MigrateFS(db *sql.DB, migrationsFS fs.FS, dir string) error
- func Open(config PostgresConfig) (*sql.DB, error)
- type Email
- type EmailService
- type FileError
- type Gallery
- type GalleryService
- func (service *GalleryService) ByID(id int) (*Gallery, error)
- func (service *GalleryService) ByUserID(userID int) ([]Gallery, error)
- func (service *GalleryService) Create(title string, userID int) (*Gallery, error)
- func (service *GalleryService) CreateImage(id int, filename string, contents io.ReadSeeker) error
- func (service *GalleryService) Delete(id int) error
- func (service *GalleryService) DeleteImage(id int, filename string) error
- func (service *GalleryService) Image(id int, filename string) (Image, error)
- func (service *GalleryService) Images(id int) ([]Image, error)
- func (service *GalleryService) Update(gallery *Gallery) error
- type Image
- type PasswordReset
- type PasswordResetService
- type PostgresConfig
- type SMTPConfig
- type Session
- type SessionService
- type TokenManager
- type User
- type UserService
Constants ¶
View Source
const (
DefaultResetDuration = 1 * time.Hour
)
View Source
const (
DefaultSender = "[email protected]"
)
View Source
const (
MinBytesPerToken = 32
)
Variables ¶
View Source
var ( ErrEmailTaken = errors.New("models: email address is already taken") ErrNotFound = errors.New("models: resource not found") )
Functions ¶
Types ¶
type EmailService ¶
type EmailService struct { DefaultSender string // DefaultSender is used as the default sender when there is not provided for an email. // contains filtered or unexported fields }
func NewEmailService ¶
func NewEmailService(config SMTPConfig) *EmailService
func (*EmailService) ForgotPassword ¶
func (es *EmailService) ForgotPassword(to, resetURL string) error
func (*EmailService) Send ¶
func (es *EmailService) Send(email Email) error
type GalleryService ¶
type GalleryService struct { DB *sql.DB // ImagesDir is the path to the directory where images are stored. Defaults to "images/". ImagesDir string }
func (*GalleryService) ByUserID ¶
func (service *GalleryService) ByUserID(userID int) ([]Gallery, error)
func (*GalleryService) Create ¶
func (service *GalleryService) Create(title string, userID int) (*Gallery, error)
func (*GalleryService) CreateImage ¶
func (service *GalleryService) CreateImage(id int, filename string, contents io.ReadSeeker) error
func (*GalleryService) Delete ¶
func (service *GalleryService) Delete(id int) error
func (*GalleryService) DeleteImage ¶
func (service *GalleryService) DeleteImage(id int, filename string) error
func (*GalleryService) Image ¶
func (service *GalleryService) Image(id int, filename string) (Image, error)
func (*GalleryService) Update ¶
func (service *GalleryService) Update(gallery *Gallery) error
type PasswordReset ¶
type PasswordResetService ¶
type PasswordResetService struct { DB *sql.DB TokenManager TokenManager Duration time.Duration // Amount of time that PasswordReset is valid for. }
func (*PasswordResetService) Consume ¶
func (service *PasswordResetService) Consume(token string) (*User, error)
func (*PasswordResetService) Create ¶
func (service *PasswordResetService) Create(email string) (*PasswordReset, error)
type PostgresConfig ¶
type PostgresConfig struct { Host string Port string User string Password string Database string SSLMode string }
func (PostgresConfig) String ¶
func (config PostgresConfig) String() string
type SessionService ¶
type SessionService struct { DB *sql.DB TokenManager TokenManager }
func (*SessionService) Delete ¶
func (ss *SessionService) Delete(token string) error
type TokenManager ¶
type TokenManager struct {
BytesPerToken int
}
func (TokenManager) New ¶
func (tm TokenManager) New() (token, tokenHash string, err error)
type UserService ¶
func (UserService) Authenticate ¶
func (us UserService) Authenticate(email, password string) (*User, error)
func (*UserService) UpdatePassword ¶
func (us *UserService) UpdatePassword(userID int, password string) error
Click to show internal directories.
Click to hide internal directories.