package main import ( "flag" "fmt" "log" "net" "net/http" "os" "example/hello/api" "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" m "github.com/oapi-codegen/nethttp-middleware" ) func main() { port := flag.String("port", "3000", "Port for test HTTP server") flag.Parse() swagger, err := api.GetSwagger() if err != nil { fmt.Fprintf(os.Stderr, "Error loading swagger spec\n: %s", err) os.Exit(1) } swagger.Servers = nil petStore := api.NewPetStore() r := chi.NewRouter() r.Use(m.OapiRequestValidator(swagger)) r.Use(middleware.Logger) // r.Get("/", func(w http.ResponseWriter, r *http.Request) { // w.Write([]byte("Hello World!")) // }) api.HandlerFromMux(petStore, r) s := &http.Server{ Handler: r, Addr: net.JoinHostPort("0.0.0.0", *port), } // And we serve HTTP until the world ends. log.Fatal(s.ListenAndServe()) }