Documentation
¶
Index ¶
- Variables
- func AuthMiddleware(cookieProc *CookiesProcessor, jwtProc *JWTProcessor, log *slog.Logger) func(next echo.HandlerFunc) echo.HandlerFunc
- func HTTPErrorHandler(log *slog.Logger) func(err error, c echo.Context)
- func NewRouter(ctx context.Context, conf *config.API, deps Dependencies) http.Handler
- type AuthDependencies
- type AuthHandler
- type Claims
- type CookiesProcessor
- func (p *CookiesProcessor) ExpireAccessTokenCookie() *http.Cookie
- func (p *CookiesProcessor) ExpireAuthTokenCookie() *http.Cookie
- func (p *CookiesProcessor) GetAccessToken(c echo.Context) (string, bool)
- func (p *CookiesProcessor) GetAuthToken(c echo.Context) (string, bool)
- func (p *CookiesProcessor) NewAccessTokenCookie(token string) *http.Cookie
- func (p *CookiesProcessor) NewAuthTokenCookie(token string) *http.Cookie
- type CustomValidator
- type DeleteWordRequest
- type Dependencies
- type ErrorResponse
- type Guessed
- type JWTProcessor
- type MarkToReviewRequest
- type StatsHandler
- type StatsQueryParams
- type TelegramClient
- type WordTranslation
- type WordsHandler
- type WordsQueryParams
Constants ¶
This section is empty.
Variables ¶
View Source
var ( InternalServerError = ErrorResponse{"Internal server error"} //nolint:gochecknoglobals // this is a constant response for internal server error BadRequestError = ErrorResponse{"Bad request"} //nolint:gochecknoglobals // this is a constant response for bad request )
Functions ¶
func AuthMiddleware ¶
func AuthMiddleware(cookieProc *CookiesProcessor, jwtProc *JWTProcessor, log *slog.Logger) func(next echo.HandlerFunc) echo.HandlerFunc
Types ¶
type AuthDependencies ¶
type AuthDependencies struct {
Repo dal.AuthConfirmationRepository
JWTProcessor *JWTProcessor
CookiesProcessor *CookiesProcessor
TelegramClient TelegramClient
AllowedChatIDs []int64
Logger *slog.Logger
}
type AuthHandler ¶
type AuthHandler struct {
// contains filtered or unexported fields
}
func NewAuthHandler ¶
func NewAuthHandler(deps AuthDependencies) *AuthHandler
type Claims ¶
type Claims struct {
Username string `json:"username"`
jwt.RegisteredClaims
}
type CookiesProcessor ¶
type CookiesProcessor struct {
// contains filtered or unexported fields
}
func NewCookiesProcessor ¶
func NewCookiesProcessor(conf config.Cookie) *CookiesProcessor
func (*CookiesProcessor) ExpireAccessTokenCookie ¶
func (p *CookiesProcessor) ExpireAccessTokenCookie() *http.Cookie
func (*CookiesProcessor) ExpireAuthTokenCookie ¶
func (p *CookiesProcessor) ExpireAuthTokenCookie() *http.Cookie
func (*CookiesProcessor) GetAccessToken ¶
func (p *CookiesProcessor) GetAccessToken(c echo.Context) (string, bool)
func (*CookiesProcessor) GetAuthToken ¶
func (p *CookiesProcessor) GetAuthToken(c echo.Context) (string, bool)
func (*CookiesProcessor) NewAccessTokenCookie ¶
func (p *CookiesProcessor) NewAccessTokenCookie(token string) *http.Cookie
func (*CookiesProcessor) NewAuthTokenCookie ¶
func (p *CookiesProcessor) NewAuthTokenCookie(token string) *http.Cookie
type CustomValidator ¶
type CustomValidator struct {
// contains filtered or unexported fields
}
func NewCustomValidator ¶
func NewCustomValidator() *CustomValidator
func (*CustomValidator) Validate ¶
func (cv *CustomValidator) Validate(i interface{}) error
type DeleteWordRequest ¶
type DeleteWordRequest struct {
Word string `json:"word" validate:"required,min=1"`
}
type Dependencies ¶
type Dependencies struct {
Repo dal.Repository
TelegramClient TelegramClient
Logger *slog.Logger
}
type ErrorResponse ¶
type ErrorResponse struct {
Message string `json:"error"`
}
type JWTProcessor ¶
type JWTProcessor struct {
// contains filtered or unexported fields
}
func NewJWTProcessor ¶
func NewJWTProcessor(conf config.JWT, authExpireIn, accessExpireIn time.Duration) *JWTProcessor
func (*JWTProcessor) ParseAccessToken ¶
func (p *JWTProcessor) ParseAccessToken(token string) (int64, error)
func (*JWTProcessor) ParseAuthToken ¶
func (p *JWTProcessor) ParseAuthToken(token string) (int64, string, error)
func (*JWTProcessor) ToAccessToken ¶
func (p *JWTProcessor) ToAccessToken(chatID int64) (string, error)
func (*JWTProcessor) ToAuthToken ¶
func (p *JWTProcessor) ToAuthToken(chatID int64, key string) (string, error)
type MarkToReviewRequest ¶
type StatsHandler ¶
type StatsHandler struct {
// contains filtered or unexported fields
}
func NewStatsHandler ¶
func NewStatsHandler(repo dal.StatsRepository, log *slog.Logger) *StatsHandler
func (*StatsHandler) GetStatsRange ¶
func (h *StatsHandler) GetStatsRange(c echo.Context) error
func (*StatsHandler) TotalStats ¶
func (h *StatsHandler) TotalStats(c echo.Context) error
type StatsQueryParams ¶
type TelegramClient ¶
type WordTranslation ¶
type WordTranslation struct {
Word string `json:"word" validate:"required,min=1"`
NewWord string `json:"new_word,omitempty" validate:"omitempty,min=1"`
Translation string `json:"translation" validate:"required,min=1"`
Description string `json:"description"`
ToReview bool `json:"to_review"`
GuessedStreak int `json:"guessed_streak,omitempty"`
}
type WordsHandler ¶
type WordsHandler struct {
// contains filtered or unexported fields
}
func NewWordsHandler ¶
func NewWordsHandler(repo dal.WordTranslationsRepository, log *slog.Logger) *WordsHandler
func (*WordsHandler) CreateWord ¶
func (h *WordsHandler) CreateWord(c echo.Context) error
func (*WordsHandler) DeleteWord ¶
func (h *WordsHandler) DeleteWord(c echo.Context) error
func (*WordsHandler) MarkToReview ¶
func (h *WordsHandler) MarkToReview(c echo.Context) error
func (*WordsHandler) UpdateWord ¶
func (h *WordsHandler) UpdateWord(c echo.Context) error
type WordsQueryParams ¶
Click to show internal directories.
Click to hide internal directories.