Documentation
¶
Index ¶
- Constants
- func IsInternalServerError(err error) bool
- func IsNotFoundError(err error) bool
- func IsOutdatedResourceError(err error) bool
- func IsResourceAlreadyCreatedError(err error) bool
- func IsUnauthorizedError(err error) bool
- func NewInternalServerError(key string) error
- func NewNotFoundError(key string) error
- func NewOutdatedResourceError(key string) error
- func NewResourceAlreadyCreatedError(key string) error
- func NewUnauthorizedError(key string, subjectAndMessage ...string) error
- type CfgDatabase
- type CfgHTTP
- type CfgMailer
- type CfgStripe
- type Config
- type ErrorWithKey
- type InternalServerError
- type NotFoundError
- type OutdatedResourceError
- type ResourceAlreadyCreatedError
- type Session
- type SessionFinder
- type SessionService
- type SessionStore
- type StoreManager
- type UnauthorizedError
- type User
- type UserFinder
- type UserService
- func (s *UserService) ChangeEmail(ctx context.Context, user *User, currentPassword string, newEmail string) (*User, error)
- func (s *UserService) ChangePassword(ctx context.Context, user *User, currentPassword string, newPassword string) (*User, error)
- func (s *UserService) CreateUser(ctx context.Context, user *User) (*User, error)
- func (s *UserService) GetByID(ctx context.Context, ID string) (*User, error)
- type UserStore
- type Validator
Constants ¶
const (
// Version represents the current version of the project
Version = "0.1.0-DEV"
)
Variables ¶
This section is empty.
Functions ¶
func IsInternalServerError ¶
IsInternalServerError identify an error as an InternalServerError
func IsNotFoundError ¶
IsNotFoundError identify an error as an NotFoundError
func IsOutdatedResourceError ¶
IsResourceAlreadyCreatedError identify an error as a ResourceAlreadyCreatedError
func IsResourceAlreadyCreatedError ¶
IsResourceAlreadyCreatedError identify an error as a ResourceAlreadyCreatedError
func IsUnauthorizedError ¶
IsUnauthorizedError identifies an error as UnauthorizedError
func NewInternalServerError ¶
NewInternalServerError is used when an error unexpected appears
func NewNotFoundError ¶
NewNotFoundError is used when we cannot find a specified resource
func NewOutdatedResourceError ¶
NewOutdatedResourceError is used when a resource already exist and could not be created another time
func NewResourceAlreadyCreatedError ¶
NewResourceAlreadyExist is used when a resource already exist and could not be created another time
func NewUnauthorizedError ¶
NewUnauthorizedError is used when the action is not authorized
Types ¶
type CfgDatabase ¶
type Config ¶
type Config struct {
Database CfgDatabase `json:"database"`
HTTP CfgHTTP `json:"http"`
Mailer CfgMailer `json:"mailer"`
Stripe CfgStripe `json:"stripe"`
DomainURL string `json:"domain_url"`
}
type ErrorWithKey ¶
type ErrorWithKey struct {
Key string
}
func (*ErrorWithKey) Error ¶
func (e *ErrorWithKey) Error() string
type InternalServerError ¶
type InternalServerError struct {
ErrorWithKey
}
InternalServerError is used when an error unexpected appears
type NotFoundError ¶
type NotFoundError struct {
ErrorWithKey
}
NotFoundError is used when we cannot find a specified resource
type OutdatedResourceError ¶
type OutdatedResourceError struct {
ErrorWithKey
}
ResourceAlreadyCreatedError is used when a resource already exist and could not be created another time
type ResourceAlreadyCreatedError ¶
type ResourceAlreadyCreatedError struct {
ErrorWithKey
}
ResourceAlreadyCreatedError is used when a resource already exist and could not be created another time
type SessionFinder ¶
type SessionService ¶
type SessionService struct {
StoreManager *StoreManager
}
type SessionStore ¶
type StoreManager ¶
type StoreManager struct {
UserStore UserStore
UserFinder UserFinder
SessionStore SessionStore
SessionFinder SessionFinder
}
StoreManager handle all the different stores accessible
type UnauthorizedError ¶
type UnauthorizedError struct {
}
UnauthorizedError is used when action is not authorized
type User ¶
type User struct {
// IDs
ID string `json:"id"`
// CustomerID is related to Stripe
CustomerID string `json:"customer_id"`
// Login information
Email string `json:"email"`
Password string `json:"-"`
// Personal information
Firstname string `json:"firstname"`
Lastname string `json:"lastname"`
Username string `json:"username"`
PhoneNumber string `json:"phone_number"`
// Status
Admin bool `json:"admin"`
// Steps date
CreatedAt time.Time `json:"created_at"`
ConfirmedAt time.Time `json:"confirmed_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt time.Time `json:"deleted_at"`
}
User defines all the fields that represent a user
type UserFinder ¶
type UserFinder interface {
ByEmail(email string) (*User, error)
ByID(id string) (*User, error)
List() ([]User, error)
}
UserFinder defines all the methods usable to read data in the store for users
type UserService ¶
type UserService struct {
StoreManager *StoreManager
}