这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -729,16 +729,18 @@ I was run with debug:false host: port:8888
To do useful work, you will want to register a handler for the default start command and optionally a way to gracefully shutdown the server:

```go
cli.OnStart(func() {
// Start your server here
http.ListenAndServe(
fmt.Sprintf("%s:%d", options.Host, options.Port), myRouter
)
})
cli := huma.NewCLI(func(hooks huma.Hooks, opts *Options) {
hooks.OnStart(func() {
// Start your server here
http.ListenAndServe(
fmt.Sprintf("%s:%d", opts.Host, opts.Port), myRouter,
)
})

cli.OnStop(func() {
// Gracefully shutdown your server here
// ...
hooks.OnStop(func() {
// Gracefully shutdown your server here
// ...
})
})
```

Expand Down