utils

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserRegistered = "User registered successfully"
	UserLoggedIn   = "User logged in successfully"
	UserUpdated    = "User updated successfully"
	UserDeleted    = "User deleted successfully"
)

Variables

This section is empty.

Functions

func FromAppError

func FromAppError(w http.ResponseWriter, reqID string, err error)

func FromPgBool

func FromPgBool(b pgtype.Bool) bool

func FromPgInt4

func FromPgInt4(i pgtype.Int4) *int32

func FromPgInt32

func FromPgInt32(i pgtype.Int4) int32

func FromPgText

func FromPgText(t pgtype.Text) string

func FromPgTimestamptz

func FromPgTimestamptz(ts pgtype.Timestamptz) time.Time

func FromPgUUID

func FromPgUUID(u pgtype.UUID) uuid.UUID

func ToPgInt4

func ToPgInt4(i *int32) pgtype.Int4

func ToPgText

func ToPgText(s string) pgtype.Text

func ToPgTimestamptz

func ToPgTimestamptz(time time.Time) pgtype.Timestamptz

func ToPgUUID

func ToPgUUID(id uuid.UUID) pgtype.UUID

func WrapRepoError

func WrapRepoError(op string, err error, log *zerolog.Logger) error

func WriteError

func WriteError(w http.ResponseWriter, httpStatusCode int, reqID string, code apperror.Kind, message string)

func WriteJSON

func WriteJSON[T any](w http.ResponseWriter, status int, reqID string, message string, data T)

Types

type Error

type Error struct {
	Kind    apperror.Kind `json:"kind"` // this is ErrorCode not httpCode, its like VALIDATION_FAILED
	Message string        `json:"message,omitempty"`
}

type ErrorResponse

type ErrorResponse struct {
	Success   bool   `json:"success"`
	RequestID string `json:"request_id"`
	Error     Error  `json:"error"`
}

type SuccessResponse

type SuccessResponse[T any] struct {
	Success   bool   `json:"success"`
	RequestID string `json:"request_id"`
	Message   string `json:"message"`
	Data      T      `json:"data,omitempty"` // Omit if nil
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL