Documentation
¶
Index ¶
- Variables
- type DatabaseAdapterer
- type HttpHandler
- func (h *HttpHandler) CreateUser(c *gin.Context)
- func (h *HttpHandler) DeleteUserById(c *gin.Context)
- func (h *HttpHandler) GetAllUsers(c *gin.Context)
- func (h *HttpHandler) GetUserById(c *gin.Context)
- func (h *HttpHandler) IsUserExistsByUsername(c *gin.Context)
- func (h *HttpHandler) UpdateUserById(c *gin.Context)
- type OuterUser
- type PostgresDatabaseAdapter
- func (a *PostgresDatabaseAdapter) CreateUser(ctx context.Context, user User) (int64, error)
- func (a *PostgresDatabaseAdapter) DeleteUserById(ctx context.Context, id int64) error
- func (a *PostgresDatabaseAdapter) GetAllUsers(ctx context.Context) ([]User, error)
- func (a *PostgresDatabaseAdapter) GetIdAndPasswordByUsername(ctx context.Context, username string) (int64, string, error)
- func (a *PostgresDatabaseAdapter) GetUserById(ctx context.Context, id int64) (User, error)
- func (a *PostgresDatabaseAdapter) IsUserExistsByUsername(ctx context.Context, username string) (bool, error)
- func (a *PostgresDatabaseAdapter) UpdateUserById(ctx context.Context, id int64, user User) error
- type Service
- func (s *Service) CreateUser(ctx context.Context, outerUser OuterUser) (int64, error)
- func (s *Service) DeleteUserById(ctx context.Context, id int64) error
- func (s *Service) GetAllUsers(ctx context.Context) ([]OuterUser, error)
- func (s *Service) GetIdAndPasswordByUsername(ctx context.Context, username string) (int64, string, error)
- func (s *Service) GetUserById(ctx context.Context, id int64) (OuterUser, error)
- func (s *Service) IsUserExistsByUsername(ctx context.Context, username string) (bool, error)
- func (s *Service) UpdateUserById(ctx context.Context, id int64, outerUser OuterUser) error
- type Servicer
- type User
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrFieldUsernameIsEmpty = reqerrors.New(http.StatusBadRequest, "field 'username' is empty") ErrFieldPasswordIsEmpty = reqerrors.New(http.StatusBadRequest, "field 'password' is empty") ErrInvalidPasswordLength = reqerrors.New(http.StatusBadRequest, "invalid password length: min: 8, max: 60") ErrFieldEmailIsEmpty = reqerrors.New(http.StatusBadRequest, "field 'email' is empty") ErrEmailNotMatchPattern = reqerrors.New(http.StatusBadRequest, "email not match 'johndoe@mail.com' pattern") ErrUserAlreadyExists = reqerrors.New(http.StatusBadRequest, "a user with the given username already exists") ErrUserNotFound = reqerrors.New(http.StatusNotFound, "user not found") )
Functions ¶
This section is empty.
Types ¶
type DatabaseAdapterer ¶
type DatabaseAdapterer interface { CreateUser(ctx context.Context, user User) (int64, error) GetAllUsers(ctx context.Context) ([]User, error) GetUserById(ctx context.Context, id int64) (User, error) UpdateUserById(ctx context.Context, id int64, user User) error DeleteUserById(ctx context.Context, id int64) error IsUserExistsByUsername(ctx context.Context, username string) (bool, error) GetIdAndPasswordByUsername(ctx context.Context, username string) (int64, string, error) }
type HttpHandler ¶
type HttpHandler struct {
// contains filtered or unexported fields
}
func NewHttpHandler ¶
func NewHttpHandler(service Servicer) *HttpHandler
func (*HttpHandler) CreateUser ¶
func (h *HttpHandler) CreateUser(c *gin.Context)
func (*HttpHandler) DeleteUserById ¶
func (h *HttpHandler) DeleteUserById(c *gin.Context)
func (*HttpHandler) GetAllUsers ¶
func (h *HttpHandler) GetAllUsers(c *gin.Context)
func (*HttpHandler) GetUserById ¶
func (h *HttpHandler) GetUserById(c *gin.Context)
func (*HttpHandler) IsUserExistsByUsername ¶
func (h *HttpHandler) IsUserExistsByUsername(c *gin.Context)
func (*HttpHandler) UpdateUserById ¶
func (h *HttpHandler) UpdateUserById(c *gin.Context)
type OuterUser ¶
type PostgresDatabaseAdapter ¶
type PostgresDatabaseAdapter struct {
// contains filtered or unexported fields
}
func NewPostgresDatabaseAdapter ¶
func NewPostgresDatabaseAdapter(db *database.PostgresDatabase) *PostgresDatabaseAdapter
func (*PostgresDatabaseAdapter) CreateUser ¶
func (*PostgresDatabaseAdapter) DeleteUserById ¶
func (a *PostgresDatabaseAdapter) DeleteUserById(ctx context.Context, id int64) error
func (*PostgresDatabaseAdapter) GetAllUsers ¶
func (a *PostgresDatabaseAdapter) GetAllUsers(ctx context.Context) ([]User, error)
func (*PostgresDatabaseAdapter) GetIdAndPasswordByUsername ¶
func (*PostgresDatabaseAdapter) GetUserById ¶
func (*PostgresDatabaseAdapter) IsUserExistsByUsername ¶
func (*PostgresDatabaseAdapter) UpdateUserById ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(databaseAdapter DatabaseAdapterer) *Service
func (*Service) CreateUser ¶
func (*Service) DeleteUserById ¶
func (*Service) GetAllUsers ¶
func (*Service) GetIdAndPasswordByUsername ¶
func (*Service) GetUserById ¶
func (*Service) IsUserExistsByUsername ¶
type Servicer ¶
type Servicer interface { CreateUser(ctx context.Context, outerUser OuterUser) (int64, error) GetAllUsers(ctx context.Context) ([]OuterUser, error) GetUserById(ctx context.Context, id int64) (OuterUser, error) UpdateUserById(ctx context.Context, id int64, outerUser OuterUser) error DeleteUserById(ctx context.Context, id int64) error IsUserExistsByUsername(ctx context.Context, username string) (bool, error) GetIdAndPasswordByUsername(ctx context.Context, username string) (int64, string, error) }
Click to show internal directories.
Click to hide internal directories.