api

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package api provides HTTP handlers for the KV API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthProvider

type AuthProvider interface {
	Enabled() bool
	FilterKeysForRequest(r *http.Request, keys []string) []string
	GetRequestActor(r *http.Request) (actorType, actorName string)
}

AuthProvider defines the interface for authentication operations.

type Deps added in v0.19.0

type Deps struct {
	Store     KVStore
	Auth      AuthProvider
	Validator FormatValidator
	Git       GitService     // optional
	Events    EventPublisher // optional
}

Deps holds dependencies for the API handler.

type EventPublisher added in v0.19.0

type EventPublisher interface {
	Publish(key string, action enum.AuditAction)
}

EventPublisher defines the interface for publishing key change events.

type FormatValidator

type FormatValidator interface {
	IsValidFormat(format string) bool
}

FormatValidator defines the interface for format validation.

type GitService

type GitService interface {
	Commit(req git.CommitRequest) error
	Delete(key string, author git.Author) error
	History(key string, limit int) ([]git.HistoryEntry, error)
	GetRevision(key string, rev string) ([]byte, string, error)
}

GitService defines the interface for git operations.

type Handler

type Handler struct {
	Deps
}

Handler handles API requests for /kv/* endpoints.

func New

func New(deps Deps) *Handler

New creates a new API handler.

func (*Handler) Register

func (h *Handler) Register(r *routegroup.Bundle)

Register registers API routes on the given router.

type KVStore

type KVStore interface {
	Get(ctx context.Context, key string) ([]byte, error)
	GetWithFormat(ctx context.Context, key string) ([]byte, string, error)
	Set(ctx context.Context, key string, value []byte, format string) (created bool, err error)
	Delete(ctx context.Context, key string) error
	List(ctx context.Context, filter enum.SecretsFilter) ([]store.KeyInfo, error)
	SecretsEnabled() bool
}

KVStore defines the interface for key-value storage operations.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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