rest

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MPL-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnforceResourceVisibility

func EnforceResourceVisibility(ctx context.Context, resourceVisibility db_model.ResourceVisibility) error

func InternalError

func InternalError(op string, err error) error

func MethodHandleFunc

func MethodHandleFunc[T any](fn func(req *http.Request) (*T, error)) http.Handler

func NewErrorResponseStatus

func NewErrorResponseStatus[T any](err error, code int) *model.Response[T]

func NewHandler

func NewHandler(dbconn *sql.DB) http.Handler

func NewResponse

func NewResponse[T any](data *T, err error) *model.Response[T]

func ParseGenericJSON

func ParseGenericJSON[T any](req *http.Request) (T, error)

func ParseUUID

func ParseUUID(val string) (uuid.UUID, error)

func ParseUUIDSet

func ParseUUIDSet(val string) (uuid.UUIDs, error)

func ResourceVisibilityFilter

func ResourceVisibilityFilter(ctx context.Context, idFilter uuid.UUIDs) db_model.ResourceVisibilities

func RespondWithError

func RespondWithError(wrt http.ResponseWriter, err error)

func SliceQueriedPage

func SliceQueriedPage[T any](entres []T, page PagePointers) []T

func UnwrapSearchIndex

func UnwrapSearchIndex(index map[uuid.UUID]int, page PagePointers) []uuid.UUID

Types

type Page

type Page[T any] struct {
	PagePointers
	Entries []T  `json:"entries"`
	HasNext bool `json:"has_next"`
}

func TransformPage

func TransformPage[E any, R any](page PagePointers, entries []E, transformer func(E) R) *Page[R]

func WrapPage

func WrapPage[T any](page PagePointers, entries []T) *Page[T]

type PagePointers

type PagePointers struct {
	Limit  int `json:"limit"`
	Offset int `json:"offset"`
}

func Pagination

func Pagination(req *http.Request) PagePointers

func (*PagePointers) QueryLimit

func (pptr *PagePointers) QueryLimit() int64

func (*PagePointers) QueryOffset

func (pptr *PagePointers) QueryOffset() int64

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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