Documentation
¶
Index ¶
- Variables
- type AbstractService
- type HTTPService
- func (s HTTPService) CurrentUser(ctx *gin.Context) (user model.User, err error)
- func (s HTTPService) CurrentUserID(ctx *gin.Context) uuid.UUID
- func (s HTTPService) HTTPError(c *gin.Context, code int, message interface{})
- func (s HTTPService) HTTPPaginatedResponse(c *gin.Context, code int, data interface{}, pagination helper.Pagination)
- func (s HTTPService) HTTPResponse(c *gin.Context, code int, data interface{})
- func (s HTTPService) HTTPValidationError(c *gin.Context, err error)
- func (s HTTPService) NormalizeHTTPValidationError(err error) []string
- func (s HTTPService) Paginate(ctx *gin.Context) *helper.Pagination
- type JWTAuthService
- type UserService
- type WebsiteService
- func (s WebsiteService) Create(website *model.Website, encryptionKey string) (err error)
- func (s WebsiteService) GetAll(pagination *helper.Pagination) (websites []model.Website, err error)
- func (s WebsiteService) GetByUser(userID uuid.UUID, pagination *helper.Pagination) (websites []model.Website, err error)
Constants ¶
This section is empty.
Variables ¶
var Module = fx.Options( fx.Provide(NewHTTPService), fx.Provide(NewJWTAuthService), fx.Provide(NewUserService), fx.Provide(NewWebsiteService), )
Module exports service module.
Functions ¶
This section is empty.
Types ¶
type HTTPService ¶
type HTTPService struct {
// contains filtered or unexported fields
}
HTTPService data type.
func NewHTTPService ¶
func NewHTTPService(userService UserService) HTTPService
NewHTTPService creates a new HTTPService.
func (HTTPService) CurrentUser ¶
CurrentUser returns the current user.
func (HTTPService) CurrentUserID ¶
func (s HTTPService) CurrentUserID(ctx *gin.Context) uuid.UUID
CurrentUserID returns the current user's ID.
func (HTTPService) HTTPError ¶
func (s HTTPService) HTTPError(c *gin.Context, code int, message interface{})
HTTPError sends HTTP error response.
func (HTTPService) HTTPPaginatedResponse ¶
func (s HTTPService) HTTPPaginatedResponse(c *gin.Context, code int, data interface{}, pagination helper.Pagination)
HTTPPaginatedResponse sends HTTP response with pagination.
func (HTTPService) HTTPResponse ¶
func (s HTTPService) HTTPResponse(c *gin.Context, code int, data interface{})
HTTPResponse sends HTTP response.
func (HTTPService) HTTPValidationError ¶
func (s HTTPService) HTTPValidationError(c *gin.Context, err error)
HTTPValidationError sends HTTP validation response.
func (HTTPService) NormalizeHTTPValidationError ¶
func (s HTTPService) NormalizeHTTPValidationError(err error) []string
NormalizeHTTPValidationError Normalizes the HTTP validation error.
func (HTTPService) Paginate ¶
func (s HTTPService) Paginate(ctx *gin.Context) *helper.Pagination
Paginate returns pagination object from the request.
type JWTAuthService ¶
type JWTAuthService struct {
// contains filtered or unexported fields
}
JWTAuthService data structure.
func NewJWTAuthService ¶
func NewJWTAuthService(config lib.Config, userService UserService, logger lib.Logger) JWTAuthService
NewJWTAuthService creates a new JWTAuthService.
func (JWTAuthService) Authorize ¶
func (s JWTAuthService) Authorize(tokenString string) (user model.User, err error)
Authorize authorizes the generated token.
func (JWTAuthService) GenerateToken ¶
func (s JWTAuthService) GenerateToken(user *model.User) (response dto.OAuthResponse, err error)
GenerateToken creates jwt auth token.
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
UserService data structure.
func NewUserService ¶
func NewUserService(repository repository.UserRepository) UserService
NewUserService creates a new UserService.
func (UserService) Create ¶
func (s UserService) Create(user *model.User) error
Create creates the user.
func (UserService) GetByUsernameOrEmail ¶
func (s UserService) GetByUsernameOrEmail(username string) (user model.User, err error)
GetByUsernameOrEmail loads the user by username or email.
type WebsiteService ¶
type WebsiteService struct { AbstractService // contains filtered or unexported fields }
WebsiteService data structure.
func NewWebsiteService ¶
func NewWebsiteService(repository repository.WebsiteRepository) WebsiteService
NewWebsiteService creates a new WebsiteService.
func (WebsiteService) Create ¶
func (s WebsiteService) Create(website *model.Website, encryptionKey string) (err error)
Create creates new website.
func (WebsiteService) GetAll ¶
func (s WebsiteService) GetAll(pagination *helper.Pagination) (websites []model.Website, err error)
GetAll gets all websites.
func (WebsiteService) GetByUser ¶
func (s WebsiteService) GetByUser( userID uuid.UUID, pagination *helper.Pagination, ) (websites []model.Website, err error)
GetByUser gets all websites for given user.