Add context.Context parameter to all API methods
Enable request timeout and cancellation control by adding context.Context as the first parameter to all SDK API methods. This allows users to: - Set per-request timeouts - Cancel in-flight requests - Pass request-scoped values
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package block
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"git.dragonchain.com/dragonchain/dragonchain-prime-sdk-go/client"
|
||||
@@ -15,10 +16,10 @@ func NewBlockClient(c *client.Client) *BlockClient {
|
||||
return &BlockClient{client: c}
|
||||
}
|
||||
|
||||
func (bc *BlockClient) Get(blockID string) (*models.Block, error) {
|
||||
func (bc *BlockClient) Get(ctx context.Context, blockID string) (*models.Block, error) {
|
||||
var resp models.Block
|
||||
path := fmt.Sprintf("/api/v1/block/%s", blockID)
|
||||
err := bc.client.Get(path, &resp)
|
||||
err := bc.client.Get(ctx, path, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user