resources

package
v2.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: GPL-3.0 Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package resources defines declarative Admin API resource metadata.

Index

Constants

View Source
const (
	MaxBatchLookupKeys           = 1000
	MaxBatchLookupKeyBytes       = 256
	MaxBatchLookupAggregateBytes = 64 << 10
)

Variables

View Source
var (
	ErrInvalidBatchLookup = errors.New("invalid batch lookup")
)

Functions

func ValidateBatchResult added in v2.0.1

func ValidateBatchResult[T any](request BatchLookup, result map[string]T) error

ValidateBatchResult rejects response keys that were not requested. Missing keys are valid and are represented by omission from the result object.

Types

type BatchLookup added in v2.0.1

type BatchLookup struct {
	// contains filtered or unexported fields
}

BatchLookup is an immutable, validated repeated-query lookup request.

func ParseBatchLookup added in v2.0.1

func ParseBatchLookup(values url.Values, parameter string) (BatchLookup, error)

ParseBatchLookup accepts exactly one repeated query parameter and preserves its value order. It rejects duplicate, malformed, or excessive keys.

func ParseBatchLookupQuery added in v2.0.1

func ParseBatchLookupQuery(rawQuery, parameter string) (BatchLookup, error)

ParseBatchLookupQuery parses the raw query without discarding malformed percent-encoding, then applies the strict batch lookup contract.

func (BatchLookup) Contains added in v2.0.1

func (b BatchLookup) Contains(key string) bool

Contains reports membership in the validated request.

func (BatchLookup) Keys added in v2.0.1

func (b BatchLookup) Keys() []string

Keys returns a copy in request order.

type Endpoint added in v2.0.1

type Endpoint struct {
	Name       string `json:"name"`
	Method     string `json:"method"`
	Path       string `json:"path"`
	Permission string `json:"-"`
}

Endpoint describes an authenticated HTTP endpoint used by a module.

type Module added in v2.0.1

type Module struct {
	ID          string     `json:"id"`
	Version     string     `json:"version"`
	Title       string     `json:"title"`
	Description string     `json:"description"`
	Icon        string     `json:"icon"`
	Kind        string     `json:"kind"`
	Path        string     `json:"path"`
	Order       int        `json:"order"`
	Permission  string     `json:"-"`
	Endpoints   []Endpoint `json:"endpoints"`
}

Module is a frontend-safe description of one admin area.

type Registrar added in v2.0.1

type Registrar interface {
	RegisterModule(Module) error
	HandleModule(moduleID, pattern, permission string, handler http.Handler) error
}

Registrar registers a module manifest and its scoped HTTP handlers.

type Resource

type Resource struct {
	Name        string
	Title       string
	Description string
	Model       any
	Permissions []string
}

Resource describes a model intended for generated administration endpoints.

Jump to

Keyboard shortcuts

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