plumego

package module
v0.2.1-0...-2113d37 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: MIT Imports: 3 Imported by: 0

README

Plumego — Standard Library Web Toolkit

Go Version Status License

Plumego is a small Go HTTP toolkit built on the standard library, keeping net/http compatibility at its center: handlers are ordinary func(http.ResponseWriter, *http.Request), middleware wraps http.Handler, and application wiring stays explicit in your own main package.

The stable surface is intentionally narrow. Start with core, router, contract, and middleware; add security, store, health, log, and metrics only when those responsibilities are needed.

Why Plumego

For Go services that need more structure than raw http.ServeMux without taking on a large framework model.

Choose Plumego if you:

  • Want to understand every line of your HTTP server's wiring
  • Prefer stdlib shapes and patterns
  • Expect your service to live for years with predictable maintenance
  • Use code agents (Claude, Codex, Cursor) to assist development
  • Value small, testable, refactorable code over convenience

Plumego is NOT:

  • A "Gin/Echo replacement" (we're complementary to stdlib, not competitive with frameworks)
  • The fastest option (we optimize for clarity, not throughput)
  • "Batteries-included" (optional x/* extensions don't bloat the core)
  • For teams who want zero wiring code
Toolkit Position Best for
http.ServeMux Minimal routing Learning, trivial services
Plumego Thin layer on stdlib Production services with stable maintenance
Chi Lightweight router Function-builder middleware style
Gin Fast + convenient High-velocity prototyping
Echo Feature-rich Fully-featured applications
Fiber High performance Maximum throughput

Read docs/start/POSITIONING.md for a deeper explanation of the design philosophy and when to choose Plumego.

Quick Start

main.go:

package main

import (
	"log"
	"net/http"

	"github.com/spcent/plumego"
	"github.com/spcent/plumego/contract"
)

func main() {
	app := plumego.New()
	app.Get("/ping", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		_ = contract.WriteResponse(w, r, http.StatusOK, map[string]string{"message": "pong"}, nil)
	}))
	log.Fatal(http.ListenAndServe(":8080", app))
}

Run:

go mod init example.com/hello
go get github.com/spcent/plumego@latest
go run main.go

Open http://localhost:8080/ping. For a production-style layout, read reference/standard-service next.

For non-default address, timeouts, or TLS:

cfg := plumego.DefaultConfig()
cfg.Addr = ":9090"
app := plumego.NewWithConfig(cfg)

For production wiring with explicit logger injection, use core.New directly — see docs/start/getting-started.md.

Choose Your Starting Point

I want to build... Start here Tier
A plain JSON API reference/standard-service → stable roots only GA
REST resources with CRUD conventions reference/with-restx/rest beta
A multi-tenant SaaS API reference/with-tenantx/tenant beta
An API gateway or reverse proxy reference/with-gatewayx/gateway beta
Real-time WebSocket features reference/with-websocketx/websocket beta
An AI-backed service reference/with-aix/ai/provider experimental
A service with rich messaging/webhooks reference/with-messagingx/messaging beta
Events / pubsub reference/with-eventsx/messaging beta
Frontend / static assets reference/with-frontendx/frontend beta
Protected ops / admin routes reference/with-ops → stable roots + security GA
A gRPC + HTTP service reference/with-rpcx/rpc experimental
Observability (Prometheus / OpenTelemetry) reference/with-observabilityx/observability beta
A tenant administration console reference/with-tenant-adminx/tenant beta
Webhook ingress / delivery reference/with-webhookx/messaging beta

All paths keep reference/standard-service as the base layout; extensions are explicit additions, not alternate bootstraps.

stdlib comparison

Feature http.ServeMux plumego
Basic routing Method handling is caller-owned. Get/Post/AddRoute register one method, path, handler.
{param} extraction Caller parses path segments manually. Router matches params; read from request context.
Route groups Caller repeats prefixes manually. Groups apply a shared prefix.
Per-group middleware Caller composes handlers per subtree. Groups carry shared middleware, keeping http.Handler shape.
Named routes + reverse URL Caller builds URLs manually. Reverse URL generation via the app/router API.
Route freeze Routes mutable whenever wiring changes. Prepare freezes routes before serving.
Structured errors Caller defines every response shape. contract.WriteError is the canonical error path.
Request ID carriage Caller picks and propagates a convention. Explicit context accessors + middleware support.
Graceful lifecycle Caller builds setup and shutdown policy. Prepare, Server, Shutdown keep it explicit and reusable.

Package overview

Package Role
core App construction, route registration, middleware attachment, server lifecycle.
router Route matching, path params, groups, metadata, reverse URL generation.
contract Response writers, structured error builders, request metadata, transport binding.
middleware Transport-only middleware composition and first-party packages.
security Auth, JWT, password, security headers, input-safety, abuse guards.
store Stable storage contracts and in-memory primitives (cache, KV, file, DB, idempotency).
health Health/readiness models for app and dependency status.
log Minimal logging interfaces and a default logger.
metrics Minimal metrics contracts (counters, gauges, timings, collectors).

Optional capability families live under x/* — additions to the stable root path, not alternate layouts.

Current Status

The nine packages listed above are stable roots carrying a full v1 compatibility guarantee: signatures, package names, and behaviour are frozen for the v1.x release series.

Seven x/* extension families are beta — stable across cited release refs and suitable for production adoption with minor caveats: x/frontend, x/gateway, x/messaging, x/observability, x/rest, x/tenant, and x/websocket.

All remaining x/* extensions are experimental: APIs may change in any minor version without notice. Do not use them in production services without explicit project-level stabilization.

See STABILITY.md for the full v1 guarantee, docs/release/COMPATIBILITY.md for upgrade paths, and docs/reference/extension-stability-policy.md for detailed promotion criteria.

Agent-First Design

Plumego is maintained with an agent-first control plane: docs/ explains the architecture, specs/ records machine-checkable boundaries, tasks/ defines reviewable execution units, and reference/ shows canonical wiring. Checks under internal/checks/ enforce key boundaries locally and in CI, so automated changes produce reviewable evidence instead of implicit convention. See docs/concepts/agent-first.md for the model and adoption path, and docs/operations/agent-first-operating-reference.md for the internal operating reference.

Getting Help

First time here?

Building an app?

Choosing technology?

Troubleshooting?

Documentation

Overview

Package plumego is the convenience entry point for the plumego HTTP toolkit.

New returns an *core.App assembled from the default configuration, making it the minimal import for a new service:

app := plumego.New()
app.Get("/ping", http.HandlerFunc(pingHandler))
log.Fatal(http.ListenAndServe(":8080", app))

All routing, middleware, and lifecycle methods are on *core.App. For a non-default address, use NewWithConfig:

cfg := plumego.DefaultConfig()
cfg.Addr = ":9090"
app := plumego.NewWithConfig(cfg)

For production wiring with explicit logger injection, use core.New directly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() *core.App

New returns an *core.App assembled from DefaultConfig with no injected dependencies. It is the minimal entry point for a plumego service.

For a non-default address, timeouts, or TLS, use NewWithConfig. For explicit logger injection, use core.New.

func NewWithConfig

func NewWithConfig(cfg AppConfig) *core.App

NewWithConfig returns an *core.App assembled from the provided configuration with no injected dependencies.

Start from DefaultConfig and override only the fields your service requires:

cfg := plumego.DefaultConfig()
cfg.Addr = ":9090"
app := plumego.NewWithConfig(cfg)

func Param

func Param(r *http.Request, name string) string

Param extracts the named path parameter from the matched route. It returns an empty string when the parameter is absent.

app.Get("/users/:id", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
    id := plumego.Param(r, "id")
    ...
}))

Types

type AppConfig

type AppConfig = core.AppConfig

AppConfig is an alias for core.AppConfig. Use DefaultConfig as the starting point and override only the fields your service requires.

func DefaultConfig

func DefaultConfig() AppConfig

DefaultConfig returns the canonical baseline application configuration: address ":8080", 30 s read/write timeouts, 5 s header timeout, 1 MiB max header bytes, and HTTP/2 enabled.

type AppDependencies

type AppDependencies = core.AppDependencies

AppDependencies is an alias for core.AppDependencies.

Directories

Path Synopsis
cmd
plumego module
Package contract provides Plumego's canonical HTTP response, error, and request metadata contracts.
Package contract provides Plumego's canonical HTTP response, error, and request metadata contracts.
Package core provides Plumego's HTTP application kernel.
Package core provides Plumego's HTTP application kernel.
Package health defines transport-agnostic health state, readiness status, and component health models.
Package health defines transport-agnostic health state, readiness status, and component health models.
internal
checks/cross-extension-deps command
cross-extension-deps verifies that x/* packages do not import paths listed in their own module.yaml forbidden_imports field.
cross-extension-deps verifies that x/* packages do not import paths listed in their own module.yaml forbidden_imports field.
nethttp
Package nethttp provides a production-ready HTTP client with automatic retry and backoff.
Package nethttp provides a production-ready HTTP client with automatic retry and backoff.
semver
Package semver provides semantic versioning support without external dependencies.
Package semver provides semantic versioning support without external dependencies.
stringsx
Package stringsx provides string utility functions.
Package stringsx provides string utility functions.
Package log provides Plumego's stable logging interfaces and base logger implementations.
Package log provides Plumego's stable logging interfaces and base logger implementations.
Package metrics provides the stable metrics contracts and small in-memory base collectors.
Package metrics provides the stable metrics contracts and small in-memory base collectors.
Package middleware provides the canonical HTTP middleware composition primitive for Plumego services.
Package middleware provides the canonical HTTP middleware composition primitive for Plumego services.
abuseguard
Package abuseguard adapts stable abuse primitives to HTTP middleware.
Package abuseguard adapts stable abuse primitives to HTTP middleware.
accesslog
Package accesslog provides HTTP access logging middleware for Plumego services.
Package accesslog provides HTTP access logging middleware for Plumego services.
recovery
Package recovery provides panic recovery middleware for HTTP request handlers.
Package recovery provides panic recovery middleware for HTTP request handlers.
requestid
Package requestid provides HTTP middleware and helpers for request correlation IDs.
Package requestid provides HTTP middleware and helpers for request correlation IDs.
securityheaders
Package securityheaders provides the HTTP security-header middleware.
Package securityheaders provides the HTTP security-header middleware.
singleflight
Package singleflight provides request coalescing middleware.
Package singleflight provides request coalescing middleware.
tracing
Package tracing provides a transport-layer tracing middleware.
Package tracing provides a transport-layer tracing middleware.
Package router provides Plumego's HTTP route matching, path parameter, grouping, and reverse URL primitives.
Package router provides Plumego's HTTP route matching, path parameter, grouping, and reverse URL primitives.
security
abuse
Package abuse provides rate limiting and anti-abuse protection.
Package abuse provides rate limiting and anti-abuse protection.
authn
Package authn provides stable authentication and authorization primitives.
Package authn provides stable authentication and authorization primitives.
headers
Package headers provides HTTP security header policy primitives.
Package headers provides HTTP security header policy primitives.
input
Package input provides security-focused input validation and basic defense-in-depth sanitization utilities.
Package input provides security-focused input validation and basic defense-in-depth sanitization utilities.
jwt
Package jwt provides JSON Web Token (JWT) generation, verification, and management with key rotation support.
Package jwt provides JSON Web Token (JWT) generation, verification, and management with key rotation support.
password
Package password provides secure password hashing and strength validation.
Package password provides secure password hashing and strength validation.
Package store provides stable, transport-agnostic storage primitives.
Package store provides stable, transport-agnostic storage primitives.
cache
Package cache provides a small in-memory cache primitive with TTL-aware and memory-bounded eviction.
Package cache provides a small in-memory cache primitive with TTL-aware and memory-bounded eviction.
db
Package db provides small stdlib-shaped SQL helpers.
Package db provides small stdlib-shaped SQL helpers.
file
Package file provides stable, transport-agnostic contracts, shared types, and errors for file storage operations.
Package file provides stable, transport-agnostic contracts, shared types, and errors for file storage operations.
idempotency
Package idempotency defines stable, storage-agnostic contracts for idempotent request processing.
Package idempotency defines stable, storage-agnostic contracts for idempotent request processing.
kv
Package kvstore provides a small embedded persistent key-value primitive.
Package kvstore provides a small embedded persistent key-value primitive.
x
ai
Package ai documents Plumego's AI capability family.
Package ai documents Plumego's AI capability family.
ai/distributed
Package distributed provides distributed workflow execution capabilities.
Package distributed provides distributed workflow execution capabilities.
ai/filter
Package filter provides content filtering for AI inputs and outputs.
Package filter provides content filtering for AI inputs and outputs.
ai/instrumentation
Package instrumentation provides observability wrappers for AI components.
Package instrumentation provides observability wrappers for AI components.
ai/llmcache
Package llmcache provides intelligent caching for LLM responses.
Package llmcache provides intelligent caching for LLM responses.
ai/marketplace
Package marketplace provides an agent and workflow registry for discovering, installing, and rating AI agents and workflow templates.
Package marketplace provides an agent and workflow registry for discovering, installing, and rating AI agents and workflow templates.
ai/metrics
Package metrics provides AI-specific observability interfaces for the x/ai extension family.
Package metrics provides AI-specific observability interfaces for the x/ai extension family.
ai/multimodal
Package multimodal provides multimodal content support for AI providers.
Package multimodal provides multimodal content support for AI providers.
ai/orchestration
Package orchestration provides agent workflow orchestration.
Package orchestration provides agent workflow orchestration.
ai/prompt
Package prompt provides template management for AI prompts.
Package prompt provides template management for AI prompts.
ai/provider
Package provider provides a unified interface for LLM providers.
Package provider provides a unified interface for LLM providers.
ai/resilience
Package resilience provides resilience wrappers for AI providers.
Package resilience provides resilience wrappers for AI providers.
ai/semanticcache
Package semanticcache provides semantic caching for LLM responses using embeddings.
Package semanticcache provides semantic caching for LLM responses using embeddings.
ai/session
Package session provides conversation session management for AI agents.
Package session provides conversation session management for AI agents.
ai/sse
Package sse provides Server-Sent Events (SSE) support for streaming AI responses.
Package sse provides Server-Sent Events (SSE) support for streaming AI responses.
ai/streaming
Package streaming provides real-time progress updates for AI workflow orchestration.
Package streaming provides real-time progress updates for AI workflow orchestration.
ai/tokenizer
Package tokenizer provides token counting for AI models.
Package tokenizer provides token counting for AI models.
ai/tool
Package tool provides function calling framework for AI agents.
Package tool provides function calling framework for AI agents.
data
Package data provides topology-heavy data capabilities that do not belong in the stable store layer.
Package data provides topology-heavy data capabilities that do not belong in the stable store layer.
data/cache
Package cache provides extension-layer cache adapters and topology-heavy cache implementations.
Package cache provides extension-layer cache adapters and topology-heavy cache implementations.
data/cache/leaderboard
Package leaderboard provides Plumego-local in-memory ranked-data cache behavior on top of the stable store/cache primitives.
Package leaderboard provides Plumego-local in-memory ranked-data cache behavior on top of the stable store/cache primitives.
data/cache/redis
Package redis adapts caller-owned Redis clients to store/cache.Cache.
Package redis adapts caller-owned Redis clients to store/cache.Cache.
data/file
Package file provides tenant-aware file storage implementations backed by the store/file interfaces.
Package file provides tenant-aware file storage implementations backed by the store/file interfaces.
data/internal/testx
Package testx provides shared test utilities for x/data subpackages.
Package testx provides shared test utilities for x/data subpackages.
data/kvengine
Package kvengine provides a durable embedded key-value engine with WAL.
Package kvengine provides a durable embedded key-value engine with WAL.
data/migrate
Package migrate defines a dependency-free migration runner contract for x/data callers.
Package migrate defines a dependency-free migration runner contract for x/data callers.
data/pgx
Package pgx defines a small explicit PostgreSQL-style query and transaction surface for x/data callers without importing a concrete driver.
Package pgx defines a small explicit PostgreSQL-style query and transaction surface for x/data callers without importing a concrete driver.
data/sharding
Package sharding provides database sharding strategies and utilities for horizontal data partitioning across multiple database instances.
Package sharding provides database sharding strategies and utilities for horizontal data partitioning across multiple database instances.
data/sqlx
Package sqlx defines a small explicit database/sql query and transaction surface for x/data callers.
Package sqlx defines a small explicit database/sql query and transaction surface for x/data callers.
fileapi
Package fileapi provides an HTTP handler for tenant-aware file operations.
Package fileapi provides an HTTP handler for tenant-aware file operations.
frontend
Package frontend provides explicit static and embedded asset serving for single-page applications and other frontend distributions.
Package frontend provides explicit static and embedded asset serving for single-page applications and other frontend distributions.
gateway
Package gateway provides reverse proxy handlers for plumego
Package gateway provides reverse proxy handlers for plumego
gateway/cache
Package cache provides HTTP response caching middleware
Package cache provides HTTP response caching middleware
gateway/discovery
Package discovery provides service discovery interfaces and implementations
Package discovery provides service discovery interfaces and implementations
gateway/ipc
Package ipc provides cross-platform inter-process communication (IPC) primitives.
Package ipc provides cross-platform inter-process communication (IPC) primitives.
gateway/protocol
Package protocol provides interface contracts for gateway protocol adapters.
Package protocol provides interface contracts for gateway protocol adapters.
gateway/transform
Package transform provides request/response transformation middleware
Package transform provides request/response transformation middleware
messaging/mq
Package mq provides an in-process message broker with advanced features.
Package mq provides an in-process message broker with advanced features.
messaging/scheduler
Package scheduler provides lightweight in-process cron and delayed job scheduling.
Package scheduler provides lightweight in-process cron and delayed job scheduling.
messaging/webhook
Package webhookin provides webhook receiver functionality with signature verification.
Package webhookin provides webhook receiver functionality with signature verification.
observability/tracer
Package tracer provides a distributed tracing subsystem: Tracer, Span, Trace, TraceCollector, Sampler, and tracing ID types.
Package tracer provides a distributed tracing subsystem: Tracer, Span, Trace, TraceCollector, Sampler, and tracing ID types.
resilience
Package resilience provides reusable circuit breaker and rate limiter primitives for the extension layer.
Package resilience provides reusable circuit breaker and rate limiter primitives for the extension layer.
resilience/circuitbreaker
Package circuitbreaker provides circuit breaker pattern implementation
Package circuitbreaker provides circuit breaker pattern implementation
resilience/ratelimit
Package ratelimit provides a reusable token bucket rate limiter.
Package ratelimit provides a reusable token bucket rate limiter.
rest
Package rest provides REST resource controller primitives, query helpers, and pagination utilities for building CRUD HTTP APIs on top of the standard library.
Package rest provides REST resource controller primitives, query helpers, and pagination utilities for building CRUD HTTP APIs on top of the standard library.
rest/versioning
Package versioning provides API version negotiation middleware
Package versioning provides API version negotiation middleware
rpc/client
Package client provides transport-neutral RPC client pooling and unary interceptor helpers.
Package client provides transport-neutral RPC client pooling and unary interceptor helpers.
rpc/gateway
Package gateway adapts caller-owned RPC HTTP handlers to net/http.
Package gateway adapts caller-owned RPC HTTP handlers to net/http.
rpc/server
Package server wraps caller-owned RPC runtimes with explicit lifecycle helpers.
Package server wraps caller-owned RPC runtimes with explicit lifecycle helpers.
tenant
Package tenant is the multi-tenancy extension surface for Plumego.
Package tenant is the multi-tenancy extension surface for Plumego.
tenant/config
Package config contains tenant configuration contracts, database-backed management helpers, and schema assets for tenant-owned configuration state.
Package config contains tenant configuration contracts, database-backed management helpers, and schema assets for tenant-owned configuration state.
tenant/core
Package tenant provides multi-tenancy infrastructure (EXPERIMENTAL).
Package tenant provides multi-tenancy infrastructure (EXPERIMENTAL).
tenant/policy
Package policy contains tenant policy evaluation helpers and middleware.
Package policy contains tenant policy evaluation helpers and middleware.
tenant/quota
Package quota contains tenant quota management helpers and middleware.
Package quota contains tenant quota management helpers and middleware.
tenant/ratelimit
Package ratelimit contains tenant rate limit helpers and middleware.
Package ratelimit contains tenant rate limit helpers and middleware.
tenant/resolve
Package resolve contains tenant resolution helpers and middleware.
Package resolve contains tenant resolution helpers and middleware.
tenant/session
Package session defines session lifecycle types and interfaces for x/tenant.
Package session defines session lifecycle types and interfaces for x/tenant.
tenant/store/cache
Package cache contains tenant-aware cache adapters.
Package cache contains tenant-aware cache adapters.
tenant/store/db
Package db contains tenant-aware database adapters.
Package db contains tenant-aware database adapters.
tenant/transport
Package transport contains tenant-specific transport mapping helpers.
Package transport contains tenant-specific transport mapping helpers.
websocket
Package websocket provides an experimental WebSocket server with room-based broadcasting.
Package websocket provides an experimental WebSocket server with room-based broadcasting.

Jump to

Keyboard shortcuts

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