Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(FAQ): "how can I use an unsupported, but net/http compliant library?" #1570

Open
jamietanna opened this issue Apr 20, 2024 · 0 comments

Comments

@jamietanna
Copy link
Member

jamietanna commented Apr 20, 2024

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())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant