mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-18 18:17:03 +00:00
feature: Context support for REST client (#496)
* rest/client: add WithContext methods Signed-off-by: James Hillyerd <james@hillyerd.com> * cmd/client: pass context Signed-off-by: James Hillyerd <james@hillyerd.com> --------- Signed-off-by: James Hillyerd <james@hillyerd.com>
This commit is contained in:
@@ -28,18 +28,20 @@ func (*listCmd) Usage() string {
|
||||
func (l *listCmd) SetFlags(f *flag.FlagSet) {}
|
||||
|
||||
func (l *listCmd) Execute(
|
||||
_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
|
||||
ctx context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
|
||||
mailbox := f.Arg(0)
|
||||
if mailbox == "" {
|
||||
return usage("mailbox required")
|
||||
}
|
||||
|
||||
// Setup rest client
|
||||
c, err := client.New(baseURL())
|
||||
if err != nil {
|
||||
return fatal("Couldn't build client", err)
|
||||
}
|
||||
|
||||
// Get list
|
||||
headers, err := c.ListMailbox(mailbox)
|
||||
headers, err := c.ListMailboxWithContext(ctx, mailbox)
|
||||
if err != nil {
|
||||
return fatal("REST call failed", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user