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:
2025-12-29 11:00:13 -05:00
parent 5576cced09
commit eb6100b736
8 changed files with 140 additions and 64 deletions

View File

@@ -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
}