Skip to content

Commit

Permalink
Add default Server object
Browse files Browse the repository at this point in the history
Give better experience if config.Servers is unset
  • Loading branch information
yursan9 committed Sep 19, 2024
1 parent 3649df3 commit d4239df
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions adapters/humago/humago.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})
}

0 comments on commit d4239df

Please sign in to comment.