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

go get github.com/go-openapi/runtime/server-middleware

What’s in it

PackageUse it for
mediatypeParsed RFC 7231 media-type values, Set lists and asymmetric matching — the building block both negotiate and the runtime’s own server pipeline use.
negotiateServer-side selection from Accept (ContentType) and Accept-Encoding (ContentEncoding). Honours MIME parameters by default; opt out with WithIgnoreParameters.
negotiate/headerLow-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.
docuiStdlib-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.