Documentation
¶
Overview ¶
Package requestcore is the v2 module of requestCore.
v2 is a typed, framework-neutral HTTP toolkit built on a canonical kernel. It requires Go 1.22+ for the net/http ServeMux pattern matching and Go 1.27+ for generic methods on typed endpoints.
Architecture ¶
The v2 kernel is organized as a layered DAG:
- request — stdlib-only request state, lazy body source, typed values, response metadata, before-commit hooks.
- telemetry — stdlib-only event/sink contracts and slog sink.
- binding, validation, operation, renderers — leaf capabilities.
- response — Problems (RFC 9457), mapper registry, commit coordinator, no-content/redirect helpers.
- endpoint — typed endpoint and executor; the canonical lifecycle (bind → validate → execute → encode → commit → observe).
- routing — handler/middleware/router and response-transport contracts; imports request only.
- adapter — adapts typed endpoints and mapped errors to routing handlers.
- libGin, libFiber, libChi, libNetHttp — native context/transport construction for each framework.
- handlers — convenience constructors and the non-generic runtime endpoint boundary used by resources.
- resources, session, workers, app, testingtools — high-level packages with no v1 imports.
Core Features ¶
**Typed endpoints** — [handlers.Endpoint[Req, Resp]] wraps [endpoint.Endpoint[Req, Resp]] with a canonical handler signature: func(*request.Context, Req) (Resp, error).
**Transport-aware routing** — [routing.Handler] receives (*request.Context, routing.Transport), separating request state from response writing.
**RFC 9457 Problems** — [response.Problem] and [response.MapperRegistry] provide structured error responses with a frozen, immutable registry.
**Telemetry via slog** — [telemetry.Sink] and [telemetry.SlogSink] replace v1's webFramework.AddLog for the Splunk transaction pipeline.
**Framework-agnostic** — [routing.Router] and [routing.RouteGroup] work across Gin, Fiber, chi, and net/http via adapter packages.
**Pluggable renderers** — [renderers.Renderer] interface with built-in JSON, XML, text, and CSV renderers.
**Sessions** — [session.Manager] with cookie store, flash messages, and typed session access via [session.FromContext].
**Workers and scheduler** — [workers.InProcessWorker] and [workers.Scheduler] with telemetry-based observability.
**Application bootstrap** — [app.Bootstrap] composes the executor, router, worker pool, scheduler, and session manager with Problem-based error handling.
Migration from v1 ¶
See MIGRATION.md for a detailed migration guide. The v1 module (github.com/hmmftg/requestCore) remains supported and stable.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package adapter adapts typed endpoints and mapped errors to routing handlers.
|
Package adapter adapts typed endpoints and mapped errors to routing handlers. |
|
Package app provides a framework-neutral application bootstrap for v2 requestCore applications.
|
Package app provides a framework-neutral application bootstrap for v2 requestCore applications. |
|
Package binding provides framework-neutral request decoding for the redesigned v2 kernel.
|
Package binding provides framework-neutral request decoding for the redesigned v2 kernel. |
|
cmd
|
|
|
requestcore
Package cmd provides the requestcore CLI for generating v2 application scaffolding, including handlers, resources, middleware, and project structure.
|
Package cmd provides the requestcore CLI for generating v2 application scaffolding, including handlers, resources, middleware, and project structure. |
|
requestcore/cmd
command
|
|
|
Package endpoint is the public typed endpoint descriptor and lifecycle executor for the v2 kernel.
|
Package endpoint is the public typed endpoint descriptor and lifecycle executor for the v2 kernel. |
|
examples
|
|
|
simple
command
Package main is a v2 requestCore example application using chi.
|
Package main is a v2 requestCore example application using chi. |
|
Package handlers provides the canonical v2 endpoint descriptors and registration helpers built on top of the endpoint.Executor kernel.
|
Package handlers provides the canonical v2 endpoint descriptors and registration helpers built on top of the endpoint.Executor kernel. |
|
internal
|
|
|
endpoint
Package endpoint provides the internal typed endpoint descriptor and lifecycle executor for the v2 kernel.
|
Package endpoint provides the internal typed endpoint descriptor and lifecycle executor for the v2 kernel. |
|
nextadapter
Package nextadapter: addlog_sink.go previously contained addLogSink, which forwarded telemetry events to the legacy AddLog pipeline.
|
Package nextadapter: addlog_sink.go previously contained addLogSink, which forwarded telemetry events to the legacy AddLog pipeline. |
|
Package libChi provides the v2 chi web framework adapter for requestCore.
|
Package libChi provides the v2 chi web framework adapter for requestCore. |
|
Package libFiber provides the v2 Fiber framework adapter for requestCore.
|
Package libFiber provides the v2 Fiber framework adapter for requestCore. |
|
Package libGin provides the v2 Gin framework adapter for requestCore.
|
Package libGin provides the v2 Gin framework adapter for requestCore. |
|
Package libNetHttp provides the v2 net/http framework adapter for requestCore.
|
Package libNetHttp provides the v2 net/http framework adapter for requestCore. |
|
Package operation provides immutable endpoint metadata and a registry contract shared by handlers, OpenAPI generation, policies, and the application bootstrap.
|
Package operation provides immutable endpoint metadata and a registry contract shared by handlers, OpenAPI generation, policies, and the application bootstrap. |
|
Package renderers provides pluggable content renderers for v2 response handling.
|
Package renderers provides pluggable content renderers for v2 response handling. |
|
Package request provides the stdlib-only request Context, typed value keys, and response metadata for the redesigned v2 kernel.
|
Package request provides the stdlib-only request Context, typed value keys, and response metadata for the redesigned v2 kernel. |
|
faketransport
Package faketransport provides an internal fake HTTP transport for testing the redesigned v2 kernel without any adapter.
|
Package faketransport provides an internal fake HTTP transport for testing the redesigned v2 kernel without any adapter. |
|
Package resources provides v2 resource registration with seven standard CRUD operations, inspired by Buffalo's resource pattern.
|
Package resources provides v2 resource registration with seven standard CRUD operations, inspired by Buffalo's resource pattern. |
|
Package routing provides framework-agnostic route groups, middleware, and a Router interface implemented by Gin, Fiber, and net/http+chi adapters.
|
Package routing provides framework-agnostic route groups, middleware, and a Router interface implemented by Gin, Fiber, and net/http+chi adapters. |
|
Package session provides pluggable session and flash management for v2.
|
Package session provides pluggable session and flash management for v2. |
|
Package telemetry provides framework-neutral event recording for the redesigned v2 kernel.
|
Package telemetry provides framework-neutral event recording for the redesigned v2 kernel. |
|
Package testingtools provides test utilities for v2 handler and middleware testing using the canonical kernel (*request.Context, routing.Transport, endpoint.Executor, telemetry.Sink).
|
Package testingtools provides test utilities for v2 handler and middleware testing using the canonical kernel (*request.Context, routing.Transport, endpoint.Executor, telemetry.Sink). |
|
Package validation provides struct-tag validation that returns response.Violation slices for integration with the v2 problem mapper.
|
Package validation provides struct-tag validation that returns response.Violation slices for integration with the v2 problem mapper. |
|
Package workers provides a bounded in-process worker pool with retry, tracing, and mandatory observability through telemetry.Sink.
|
Package workers provides a bounded in-process worker pool with retry, tracing, and mandatory observability through telemetry.Sink. |