Runtime & Server
Sphere’s HTTP layer builds on Gin with small helpers to keep handlers concise and error responses consistent.
Key Pieces
WithJson[T]: wraps a handler returning(T, error)and serializes responses toDataResponse[T]AbortWithJsonError: normalizes errors toErrorResponsewith proper HTTP statusShouldBindJSON/Uri/Query: thin wrappers to bind request payloads- Docs/Debug servers: auxiliary HTTP servers for Swagger UI and diagnostics
Typical Flow
- Protobuf +
protoc-gen-spheregenerate handler plumbing - Your service method returns data or a typed error
- Wrapper turns it into a stable JSON envelope for clients
Extensibility
- Customize router/context/response types via
protoc-gen-sphereflags - Provide your own error parser to merge validation or domain-specific errors
Last updated on