Documentation ¶
Index ¶
- Constants
- func BindAndValidate(ctx echo.Context, i interface{}) error
- func OptimiseImageToJPEG(image []byte, maxSize int) ([]byte, error)
- func PopElement[T comparable](toPop T, items []T) []T
- func ValueOrDefault[V comparable](value *V, def V) V
- type AuthenticatedUser
- type CreateLogin
- type JWTClaims
- type LoginToken
- type PaginationParams
- type PantryItemsFilterParams
- type RecipesFilterParams
- type SelectField
- type SelectedUpdate
Constants ¶
View Source
const APIVersionMajor uint = 0
View Source
const APIVersionMinor uint = 1
Variables ¶
This section is empty.
Functions ¶
func BindAndValidate ¶
func BindAndValidate(ctx echo.Context, i interface{}) error
Ease of use method, when binding & validation is needed.
func OptimiseImageToJPEG ¶
Optimises an image to JPEG format, ensuring that the image is no larger than maxSize
func PopElement ¶
func PopElement[T comparable](toPop T, items []T) []T
func ValueOrDefault ¶
func ValueOrDefault[V comparable](value *V, def V) V
Types ¶
type AuthenticatedUser ¶
type AuthenticatedUser struct { UserID uuid.UUID `json:"userId"` Username string `json:"username"` IsAdmin bool `json:"isAdmin"` }
func GetAuthenticatedUserFromContext ¶
func GetAuthenticatedUserFromContext(ctx echo.Context) (AuthenticatedUser, error)
Get the authenticated user
type CreateLogin ¶
type JWTClaims ¶
type JWTClaims struct { Username string `json:"username"` IsAdmin bool `json:"isAdmin"` jwt.RegisteredClaims }
func (*JWTClaims) ToAuthenticatedUser ¶
func (c *JWTClaims) ToAuthenticatedUser() (AuthenticatedUser, error)
type LoginToken ¶
type LoginToken struct { Type string `json:"type"` Token string `json:"token"` Expiry time.Time `json:"expiry"` }
func CreateAuthenticationToken ¶
func CreateAuthenticationToken(user AuthenticatedUser, secretKey []byte) (LoginToken, error)
Create token for authentication
type PaginationParams ¶
type PantryItemsFilterParams ¶
type RecipesFilterParams ¶
type RecipesFilterParams struct { PaginationParams Title *string `query:"title"` Labels []string `query:"label"` Freezable *bool `query:"freezable"` MicrowaveOnly *bool `query:"microwaveOnly"` }
type SelectField ¶
type SelectField string
func (*SelectField) UnmarshalJSON ¶
func (sf *SelectField) UnmarshalJSON(data []byte) error
type SelectedUpdate ¶
type SelectedUpdate[T any] struct { Fields []SelectField `json:"fields" validate:"required"` Model T `json:"model" validate:"required"` }
func (*SelectedUpdate[T]) FieldsAsString ¶
func (su *SelectedUpdate[T]) FieldsAsString() []string
Click to show internal directories.
Click to hide internal directories.