HTTP

Serving HTTP with the httpserver package, then serving an API of typed operations, with its OpenAPI document, with the openapi/v3 package.

An HTTP service serves an http.Handler over TLS with httpserver, which Serving HTTP covers first. Serving an API with OpenAPI then builds that handler from typed operations on typed paths with openapi/v3, which writes the API’s OpenAPI document from the same declarations.

The shoppingcart walkthrough builds a production-ready API on both, step by step, and its code is example/http/shoppingcart.


Serving HTTP

How to serve HTTP with the httpserver package: an Init that sources httpserver.Settings and returns the Service from NewService, the certificate it requires, the protocols it serves, how it drains and shuts down on httpserver.Main’s defaults, what it records, and how to test it with httpservertest.

Serving an API with OpenAPI

How to serve an API with the openapi/v3 package: an Init that builds an *openapi.API with NewAPI and serves it with httpserver.NewService, typed paths and parameters, operations and the codecs every body names, jsoncodec and codecs of one’s own, streaming ones included, the answers to errors, rejected requests, 404s and 405s, problem details, what happens on a panic or on a failure after the status, security, the OpenAPI 3.2 document, what the API records, and how to test it.