server

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: 25 Imported by: 0

Documentation

Overview

Package server provides HTTP server for the key-value store API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateAuthSchema added in v0.9.2

func GenerateAuthSchema() ([]byte, error)

GenerateAuthSchema generates JSON schema for auth.Config struct.

func VerifyAuthConfig added in v0.9.2

func VerifyAuthConfig(data []byte) error

VerifyAuthConfig validates auth config data against the embedded JSON schema.

Types

type Config

type Config struct {
	Address         string
	ReadTimeout     time.Duration
	WriteTimeout    time.Duration
	IdleTimeout     time.Duration
	ShutdownTimeout time.Duration
	Version         string
	BaseURL         string // base URL path for reverse proxy (e.g., /stash)
	PageSize        int    // keys per page in web UI (0 = unlimited)

	BodySizeLimit    int64   // max request body size in bytes
	RequestsPerSec   float64 // max requests per second (rate limit)
	MaxConcurrent    int64   // max concurrent in-flight requests
	LoginConcurrency int64   // max concurrent login attempts

	AuditEnabled    bool // enable audit logging
	AuditQueryLimit int  // max entries per audit query (default 10000)
}

Config holds server configuration.

type Deps added in v0.19.0

type Deps struct {
	Store      KVStore
	Validator  Validator
	Git        GitService    // optional, nil to disable git versioning
	Auth       *auth.Service // optional, nil to disable authentication
	AuditStore *store.Store  // optional, nil to disable audit logging
	SSE        *sse.Service  // optional, nil to disable key change subscriptions
}

Deps holds server dependencies.

type GitService added in v0.9.1

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 KVStore

type KVStore interface {
	Get(ctx context.Context, key string) ([]byte, error)
	GetWithFormat(ctx context.Context, key string) ([]byte, string, error)
	GetInfo(ctx context.Context, key string) (store.KeyInfo, error)
	Set(ctx context.Context, key string, value []byte, format string) (created bool, err error)
	SetWithVersion(ctx context.Context, key string, value []byte, format string, expectedVersion time.Time) 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.

type Server

type Server struct {
	Deps
	Config
	// contains filtered or unexported fields
}

Server represents the HTTP server.

func New

func New(deps Deps, cfg Config) (*Server, error)

New creates a new Server instance.

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run starts the HTTP server and blocks until context is canceled.

type Validator added in v0.7.0

type Validator interface {
	Validate(format string, value []byte) error
	IsValidFormat(format string) bool
	SupportedFormats() []string
}

Validator defines the interface for format validation.

Directories

Path Synopsis
api
Package api provides HTTP handlers for the KV API.
Package api provides HTTP handlers for the KV API.
Package audit provides HTTP middleware for audit logging and query handler for audit log access.
Package audit provides HTTP middleware for audit logging and query handler for audit log access.
Package auth provides authentication and authorization for the stash server.
Package auth provides authentication and authorization for the stash server.
internal
cookie
Package cookie provides shared cookie-related constants.
Package cookie provides shared cookie-related constants.
schema command
sse
Package sse provides Server-Sent Events support for real-time key change notifications.
Package sse provides Server-Sent Events support for real-time key change notifications.
web
Package web provides HTTP handlers for the web UI.
Package web provides HTTP handlers for the web UI.

Jump to

Keyboard shortcuts

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