util

package
v0.0.0-...-2d1ab9f Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCurrency = "USD"
View Source
const (
	QueryNilValue = "<nil>"
)

Variables

View Source
var (
	ErrBadRequest                   = errors.New(http.StatusText(http.StatusBadRequest))                   // ErrBadRequest indicates malformed syntax, etc.
	ErrUnauthorized                 = errors.New(http.StatusText(http.StatusUnauthorized))                 // ErrUnauthorized indicates missing credentials.
	ErrForbidden                    = errors.New(http.StatusText(http.StatusForbidden))                    // ErrForbidden indicates lack of necessary permissions.
	ErrNotFound                     = errors.New(http.StatusText(http.StatusNotFound))                     // ErrNotFound indicates resource could not be found.
	ErrMethodNotAllowed             = errors.New(http.StatusText(http.StatusMethodNotAllowed))             // ErrMethodNotAllowed indicates method not supported by resource.
	ErrNotAcceptable                = errors.New(http.StatusText(http.StatusNotAcceptable))                // ErrNotAcceptable indicates no client-acceptable media type for resource.
	ErrConflict                     = errors.New(http.StatusText(http.StatusConflict))                     // ErrConflict indicates a conflict the user must resolve and resubmit.
	ErrGone                         = errors.New(http.StatusText(http.StatusGone))                         // ErrGone indicates the resource is no longer available.
	ErrPreconditionFailed           = errors.New(http.StatusText(http.StatusPreconditionFailed))           // ErrPreconditionFailed indicates one or more request conditions are false.
	ErrUnsupportedMediaType         = errors.New(http.StatusText(http.StatusUnsupportedMediaType))         // ErrUnsupportedMediaType indicates payload media type is not supported.
	ErrRequestedRangeNotSatisfiable = errors.New(http.StatusText(http.StatusRequestedRangeNotSatisfiable)) // ErrRequestedRangeNotSatisfiable indicates the given Range cannot be satisfied.
	ErrUnprocessableEntity          = errors.New(http.StatusText(http.StatusUnprocessableEntity))          // ErrUnprocessableEntity indicates request payload is well-formed syntactically but not semantically.
	ErrLocked                       = errors.New(http.StatusText(http.StatusLocked))                       // ErrLocked indicates that the resource is currently locked.
	ErrPreconditionRequired         = errors.New(http.StatusText(http.StatusPreconditionRequired))         // ErrPreconditionRequired indicates request must be conditional but isn't.
	ErrInternalError                = errors.New(http.StatusText(http.StatusInternalServerError))          // ErrInternalError indicates an unexpected internal server error.
	ErrNotImplemented               = errors.New(http.StatusText(http.StatusNotImplemented))               // ErrNotImplemented indicates that a requested operation is not implemented.
	ErrServiceUnavailable           = errors.New(http.StatusText(http.StatusServiceUnavailable))           // ErrServiceUnavailable indicates service is currently unavailable.

)

Functions

func AddJoin

func AddJoin(selectStmt *pg_query.SelectStmt, joinType pg_query.JoinType, rightTable *pg_query.Node, condition *pg_query.Node)

func AddSetClause

func AddSetClause(updateStmt *pg_query.UpdateStmt, columnName string, paramIndex int)

func AddWhereNode

func AddWhereNode(selectStmt *pg_query.SelectStmt, node *pg_query.Node)

func ClearOrderByClause

func ClearOrderByClause(selectStmt *pg_query.SelectStmt)

func ClearWithClause

func ClearWithClause(selectStmt *pg_query.SelectStmt)

func ContextWithLogger

func ContextWithLogger(ctx context.Context, l *slog.Logger) context.Context

func GetSQL

func GetSQL(result *pg_query.ParseResult) string

func Logger

func Logger(ctx context.Context) *slog.Logger

func MakeAndExprNode

func MakeAndExprNode(left, right *pg_query.Node) *pg_query.Node

func MakeColumnRefNode

func MakeColumnRefNode(tableAlias, columnName string) *pg_query.Node

func MakeIsNotNullNode

func MakeIsNotNullNode(node *pg_query.Node) *pg_query.Node

func MakeIsNullNode

func MakeIsNullNode(node *pg_query.Node) *pg_query.Node

func MakeLikeExprNode

func MakeLikeExprNode(left, right *pg_query.Node) *pg_query.Node

func MakeOpExprNode

func MakeOpExprNode(op string, left, right *pg_query.Node) *pg_query.Node

func MakeOrExprNode

func MakeOrExprNode(left, right *pg_query.Node) *pg_query.Node

func MakeParamNode

func MakeParamNode(index int) *pg_query.Node

func Marshal

func Marshal(w http.ResponseWriter, r *http.Request, statusCode int, v any) error

func ParseRowsRange

func ParseRowsRange(r string) (int, int, error)

func RemoveLimit

func RemoveLimit(selectStmt *pg_query.SelectStmt)

func RemoveOffset

func RemoveOffset(selectStmt *pg_query.SelectStmt)

func ReplaceSelectTargetsWithCountRows

func ReplaceSelectTargetsWithCountRows(selectStmt *pg_query.SelectStmt)

func RequestWithLogger

func RequestWithLogger(r *http.Request, l *slog.Logger) *http.Request

func ServeError

func ServeError(w http.ResponseWriter, r *http.Request, err error) (httpCode int)

func SetLimit

func SetLimit(selectStmt *pg_query.SelectStmt, count int64)

func SetOffset

func SetOffset(selectStmt *pg_query.SelectStmt, offset int64)

func SetOrderBy

func SetOrderBy(selectStmt *pg_query.SelectStmt, elements []string) error

func UnmarshalBody

func UnmarshalBody(r *http.Request, v any) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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