Documentation ¶
Index ¶
- func WriteErrorResponse(w http.ResponseWriter, r *http.Request, msg string, err error)
- func WriteJSON(w http.ResponseWriter, status int, v any)
- type AccountHandler
- type AccountService
- type AuthHandler
- type AuthService
- type BalanceUpdateRequest
- type DataResponse
- type ErrorResponse
- type LoginUserRequest
- type PartialUpdateUserRequest
- type RegisterUserRequest
- type UserHandler
- type UserService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteErrorResponse ¶
Types ¶
type AccountHandler ¶
type AccountHandler struct {
// contains filtered or unexported fields
}
AccountHandler is the handler for the account service
func NewAccount ¶
func NewAccount(svc AccountService, logger *logrus.Logger, authSvc AuthService) *AccountHandler
NewAccount creates a new account handler
func (*AccountHandler) RegisterRoutes ¶
func (h *AccountHandler) RegisterRoutes(r *http.ServeMux)
RegisterRoutes connects the handlers to the router
type AccountService ¶
type AccountService interface { Create(userID int64) error GetAllByUserID(userID, offset, limit int64) ([]internal.Account, error) GetByID(userID int64, accountID int64) (internal.Account, error) DeleteByID(userID, accountID int64) error UpdateBalanceByID(userID int64, accountID int64, balance internal.USD) (internal.Account, error) }
AccountService defines the methods that the account handler will use
type AuthHandler ¶
type AuthHandler struct {
// contains filtered or unexported fields
}
func NewAuth ¶
func NewAuth(svc AuthService, logger *logrus.Logger) *AuthHandler
func (*AuthHandler) RegisterRoutes ¶
func (h *AuthHandler) RegisterRoutes(r *http.ServeMux)
type AuthService ¶
type AuthService interface { // Login returns user id and jwt token Login(email, password string) (int64, string, error) // Register hashes password and saves user Register(u internal.User) error WithJWTMiddleware(handlerFunc http.HandlerFunc) http.HandlerFunc CreateJWT(userID int64) (string, error) }
type BalanceUpdateRequest ¶
type DataResponse ¶
type ErrorResponse ¶
type LoginUserRequest ¶
type LoginUserRequest struct { Email string `json:"email" validate:"required,email"` Password string `json:"password" validate:"required"` }
LoginUserRequest defines the request payload for logging in a user
type RegisterUserRequest ¶
type RegisterUserRequest struct { FirstName string `json:"firstName" validate:"required"` LastName string `json:"lastName" validate:"required"` Email string `json:"email" validate:"required,email"` Password string `json:"password" validate:"required,min=8,max=64"` }
RegisterUserRequest defines the request payload for registering a new user
type UserHandler ¶
type UserHandler struct {
// contains filtered or unexported fields
}
UserHandler is the handler for the user service
func NewUser ¶
func NewUser(svc UserService, logger *logrus.Logger, authSvc AuthService) *UserHandler
NewUser creates a new user handler
func (*UserHandler) RegisterRoutes ¶
func (h *UserHandler) RegisterRoutes(r *http.ServeMux)
RegisterRoutes connects the handlers to the router
type UserService ¶
type UserService interface { GetAll(limit, offset int64) ([]internal.User, error) Get(id int64) (internal.User, error) GetByEmail(email string) (internal.User, error) Create(user internal.User) error Delete(id int64) error Update(id int64, user internal.User) (internal.User, error) PartialUpdate(id int64, user internal.User) (internal.User, error) }
UserService defines the methods that the user handler will use
Click to show internal directories.
Click to hide internal directories.