Documentation ¶
Index ¶
- Constants
- func CreateDBErrorResponse(err error) types.ValidationErrorResponse
- func GetNextPageURL(r *http.Request, limit, offset, totalRows int) string
- func GetPrevPageURL(r *http.Request, limit, offset int) string
- func GetSessionDetails(r *http.Request, store *session.Store) (uuid.UUID, uuid.UUID, uuid.UUID, bool)
- func GetSystemSessionName() string
- func IsValidationError(err error) bool
- func PaginationParams(r *http.Request) (int, int, error)
- func ParseBody(r *http.Request, body any) error
- func ParseBodyAndValidate(w http.ResponseWriter, r *http.Request, body any) error
- func RegisterGob()
- func ResponseWithError(w http.ResponseWriter, statusCode int, data any)
- func ResponseWithJSON(w http.ResponseWriter, statusCode int, data any)
- func WithTx(ctx context.Context, client *ent.Client, fn func(tx *ent.Tx) error) error
- type LocalFileStorage
- type StorageService
- type ValidationError
- type Validator
Constants ¶
View Source
const SplitStrNum = 2
Variables ¶
This section is empty.
Functions ¶
func CreateDBErrorResponse ¶
func CreateDBErrorResponse(err error) types.ValidationErrorResponse
CreateDBErrorResponse formats a database error into a structured response.
func GetSessionDetails ¶
func GetSessionDetails(r *http.Request, store *session.Store) (uuid.UUID, uuid.UUID, uuid.UUID, bool)
GetSessionDetails retrieves user ID, organization ID, and business unit ID from the session.
func GetSystemSessionName ¶
func GetSystemSessionName() string
func IsValidationError ¶
IsValidationError checks if the provided error is a ValidationError.
func ParseBodyAndValidate ¶
ParseBodyAndValidate parses the request body into the given struct and validates it using the given validator. If the body is invalid, it writes a 400 response with the validation error.
func RegisterGob ¶
func RegisterGob()
RegisterGob registers the UUID type with gob, so it can be used in sessions.
func ResponseWithError ¶
func ResponseWithError(w http.ResponseWriter, statusCode int, data any)
func ResponseWithJSON ¶
func ResponseWithJSON(w http.ResponseWriter, statusCode int, data any)
Types ¶
type LocalFileStorage ¶
type LocalFileStorage struct {
BaseDir string
}
func NewLocalFileStorage ¶
func NewLocalFileStorage() *LocalFileStorage
NewLocalFileStorage initializes a new LocalFileStorage with the base directory.
type StorageService ¶
type ValidationError ¶
type ValidationError struct {
Response types.ValidationErrorResponse
}
func NewValidationError ¶
func NewValidationError(message, code, attr string) *ValidationError
newValidationError creates a new ValidationError with the specified message and code.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
Click to show internal directories.
Click to hide internal directories.