From d4239dfdad1ece245d005e0a47b84a405bcfd33a Mon Sep 17 00:00:00 2001 From: Yurizal Susanto Date: Thu, 19 Sep 2024 11:49:52 +0700 Subject: [PATCH] Add default Server object Give better experience if config.Servers is unset --- adapters/humago/humago.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/adapters/humago/humago.go b/adapters/humago/humago.go index 07c63b29..12693404 100644 --- a/adapters/humago/humago.go +++ b/adapters/humago/humago.go @@ -162,5 +162,10 @@ func New(m Mux, config huma.Config) huma.API { // config.Servers = []*huma.Server{{URL: "http://example.com/api"}} // api := humago.NewWithPrefix(mux, "/api", config) func NewWithPrefix(m Mux, prefix string, config huma.Config) huma.API { + if len(config.Servers) == 0 { + config.Servers = append(config.Servers, &huma.Server{ + URL: prefix, + }) + } return huma.NewAPI(config, &goAdapter{m, prefix}) }