oapi-codegen
oapi-codegen copied to clipboard
docs(FAQ): "how can I use an unsupported, but `net/http` compliant library?"
package main
import (
"log"
"net/http"
"github.com/deepmap/oapi-codegen/v2/examples/minimal-server/gorillamux/api"
)
func main() {
// create a type that satisfies the `api.ServerInterface`, which contains an implementation of every operation from the generated code
server := api.NewServer()
// get an `http.Handler` that we can use, but don't specify the router
h := api.Handler(server)
s := &http.Server{
Handler: h,
Addr: "0.0.0.0:8080",
}
// And we serve HTTP until the world ends.
log.Fatal(s.ListenAndServe())
}