Skip to content

Commit

Permalink
Merge pull request #579 from yursan9/humago-prefix
Browse files Browse the repository at this point in the history
Add default Server object when calling humago.NewWithPrefix
  • Loading branch information
danielgtaylor authored Sep 20, 2024
2 parents a3a24c7 + d4239df commit 6781fc0
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 6781fc0

Please sign in to comment.