api

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OffsetKey   = "offset"
	LimitKey    = "limit"
	MetadataKey = "metadata"
	DefOffset   = 0
	DefLimit    = 100

	ContentType = "application/json"

	MaxLimitSize = 100
)

Variables

View Source
var (
	ErrValidation             = errors.New("something went wrong with the request")
	ErrMissingName            = errors.New("missing identity name")
	ErrMissingID              = errors.New("missing entity id")
	ErrInvalidQueryParams     = errors.New("invalid query parameters")
	ErrLimitSize              = errors.New("invalid limit size")
	ErrUnsupportedContentType = errors.New("unsupported content type")
)

Functions

func EncodeError

func EncodeError(_ context.Context, err error, w http.ResponseWriter)

func EncodeResponse

func EncodeResponse(_ context.Context, w http.ResponseWriter, response any) error

func HealthHandler added in v0.6.0

func HealthHandler(service, instanceID string) http.HandlerFunc

func LoggingErrorEncoder added in v0.6.0

func LoggingErrorEncoder(logger *slog.Logger, enc kithttp.ErrorEncoder) kithttp.ErrorEncoder

func ReadMetadataQuery added in v0.6.0

func ReadMetadataQuery(r *http.Request, key string, def map[string]any) (map[string]any, error)

func ReadNumQuery added in v0.6.0

func ReadNumQuery[N number](r *http.Request, key string, def N) (N, error)

func ReadStringQuery added in v0.6.0

func ReadStringQuery(r *http.Request, key, def string) (string, error)

Types

type Response added in v0.6.0

type Response interface {
	Code() int
	Headers() map[string]string
	Empty() bool
}

Jump to

Keyboard shortcuts

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