go-restful maps HTTP verbs to Go handlers with path parameters, filters, and content encoding. It supports JSON and XML request and response APIs for service containers.
Overview
go-restful helps Go developers expose resources over HTTP using familiar REST verb semantics. Routes tie request paths and methods to functions with path parameter support.
Services can register WebServices on different endpoints inside containers. Filters run on routes or entire services for cross-cutting behavior such as CORS and gzip compression.
The request API unmarshals JSON or XML into structs and reads query, path, and header parameters. Responses marshal structs back and set headers. Custom entity readers and writers allow alternate encodings.
Hooks cover router selection, panic recovery, logging, compression providers, and HTTP middleware integration. Error handlers customize 404 and method-not-allowed responses.
Key features
- REST route mapping
- Path parameter routes
- Request filters
- JSON and XML entities
- Gzip encoding
- CORS filter support
- Multi-endpoint containers
- Custom error handlers
Use cases
- Go microservice APIs
- Legacy REST backends
- Multi-tenant HTTP services
- Encoded JSON/XML APIs