Documentation ¶
Index ¶
- func CheckImageContentType(image *multipart.FileHeader) error
- func CheckImageFileContentType(fileContent []byte) (string, error)
- func ConfigureJWTCookie(cfg *config.Config, jwtToken string) *http.Cookie
- func CreateSessionCookie(cfg *config.Config, session string) *http.Cookie
- func DeleteSessionCookie(c echo.Context, sessionName string)
- func ErrResponseWithLog(ctx echo.Context, logger logger.Logger, err error) error
- func ExtractBearerToken(r *http.Request) string
- func ExtractJWTFromRequest(r *http.Request) (map[string]interface{}, error)
- func GenerateJWTToken(user *models.UserWithRole, config *config.Config) (string, error)
- func GetConfigPath(configPath string) string
- func GetCtxWithReqID(c echo.Context) (context.Context, context.CancelFunc)
- func GetHasMore(currentPage int, totalCount int, pageSize int) bool
- func GetIPAddress(c echo.Context) string
- func GetImageContentType(image []byte) (string, bool)
- func GetImageExtension(image *multipart.FileHeader) (string, error)
- func GetRequestCtx(c echo.Context) context.Context
- func GetRequestID(c echo.Context) string
- func GetTotalPages(totalCount int, pageSize int) int
- func GetUniqFileName(userID string, fileExtension string) string
- func GetUserFromCtx(ctx context.Context) (*models.UserWithRole, error)
- func IsAllowedImageContentType(image []byte) bool
- func IsAllowedImageHeader(image *multipart.FileHeader) bool
- func LogResponseError(ctx echo.Context, logger logger.Logger, err error)
- func ReadImage(ctx echo.Context, field string) (*multipart.FileHeader, error)
- func ReadRequest(ctx echo.Context, request interface{}) error
- func SanitizeRequest(ctx echo.Context, request interface{}) error
- func ValidateIsOwner(ctx context.Context, creatorID int, logger logger.Logger) error
- func ValidateStruct(ctx context.Context, s interface{}) error
- type Claims
- type PaginationQuery
- func (q *PaginationQuery) GetLimit() int
- func (q *PaginationQuery) GetOffset() int
- func (q *PaginationQuery) GetOrderBy() string
- func (q *PaginationQuery) GetPage() int
- func (q *PaginationQuery) GetQueryString() string
- func (q *PaginationQuery) GetSize() int
- func (q *PaginationQuery) SetOrderBy(orderByQuery string)
- func (q *PaginationQuery) SetPage(pageQuery string) error
- func (q *PaginationQuery) SetSize(sizeQuery string) error
- type ReqIDCtxKey
- type UserCtxKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckImageContentType ¶
func CheckImageContentType(image *multipart.FileHeader) error
func ConfigureJWTCookie ¶
Configure jwt cookie
func CreateSessionCookie ¶
Configure jwt cookie
func DeleteSessionCookie ¶
func DeleteSessionCookie(c echo.Context, sessionName string)
Delete session
func ErrResponseWithLog ¶
Error response with logging error for echo context
func ExtractBearerToken ¶
Extract bearer token from request Authorization header
func ExtractJWTFromRequest ¶
Extract JWT From Request
func GenerateJWTToken ¶
Generate new JWT Token
func GetConfigPath ¶
Get config path for local or docker
func GetCtxWithReqID ¶
func GetCtxWithReqID(c echo.Context) (context.Context, context.CancelFunc)
Get ctx with timeout and request id from echo context
func GetImageContentType ¶
func GetImageExtension ¶
func GetImageExtension(image *multipart.FileHeader) (string, error)
func GetUniqFileName ¶
func GetUserFromCtx ¶
func GetUserFromCtx(ctx context.Context) (*models.UserWithRole, error)
Get user from context
func IsAllowedImageHeader ¶
func IsAllowedImageHeader(image *multipart.FileHeader) bool
func LogResponseError ¶
Error response with logging error for echo context
func ReadRequest ¶
func ReadRequest(ctx echo.Context, request interface{}) error
Read request body and validate
func SanitizeRequest ¶
func SanitizeRequest(ctx echo.Context, request interface{}) error
Read sanitize and validate request
func ValidateIsOwner ¶
Validate is user from owner of content
func ValidateStruct ¶
Validate struct fields
Types ¶
type Claims ¶
type Claims struct { Email string `json:"email"` ID string `json:"id"` Role int `json:"role"` jwt.StandardClaims }
JWT Claims struct
type PaginationQuery ¶
type PaginationQuery struct { Size int `json:"size,omitempty"` Page int `json:"page,omitempty"` OrderBy string `json:"orderBy,omitempty"` }
Pagination query params
func GetPaginationFromCtx ¶
func GetPaginationFromCtx(c echo.Context) (*PaginationQuery, error)
Get pagination query struct from
func (*PaginationQuery) GetQueryString ¶
func (q *PaginationQuery) GetQueryString() string
func (*PaginationQuery) SetOrderBy ¶
func (q *PaginationQuery) SetOrderBy(orderByQuery string)
Set order by
func (*PaginationQuery) SetPage ¶
func (q *PaginationQuery) SetPage(pageQuery string) error
Set page number
func (*PaginationQuery) SetSize ¶
func (q *PaginationQuery) SetSize(sizeQuery string) error
Set page size
type ReqIDCtxKey ¶
type ReqIDCtxKey struct{}
ReqIDCtxKey is a key used for the Request ID in context
type UserCtxKey ¶
type UserCtxKey struct{}
UserCtxKey is a key used for the User object in the context