Standalone middleware
github.com/go-openapi/runtime/server-middleware is a separate Go module
that ships the negotiation, media-type and doc-UI primitives without
inheriting the OpenAPI spec / loads / validate dependency tree. Drop it
into any vanilla net/http application.
Install
What’s in it
| Package | Use it for |
|---|---|
mediatype | Parsed RFC 7231 media-type values, Set lists and asymmetric matching — the building block both negotiate and the runtime’s own server pipeline use. |
negotiate | Server-side selection from Accept (ContentType) and Accept-Encoding (ContentEncoding). Honours MIME parameters by default; opt out with WithIgnoreParameters. |
negotiate/header | Low-level RFC 7231 header parsing primitives reused by negotiate. Use it directly if you need raw Accept/Accept-Encoding parsing without the typed media-type layer. |
docui | Stdlib-only handlers that serve Swagger UI, RapiDoc or Redoc, plus the spec document itself. Mountable on any net/http mux. |
The module has zero transitive dependencies on go-openapi/spec,
go-openapi/loads, go-openapi/validate, or even on the rest of
go-openapi/runtime. Standard library only.
- Typed RFC 7231 media-type values, sets and asymmetric matching via the mediatype package.
- Accept and Accept-Encoding selection via the negotiate package, including the new MIME-parameter-aware default.
- Stdlib-only Swagger UI, RapiDoc, Redoc and spec-serving handlers from the docui package.