Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewContext ¶
NewContext stores the client in the given context and returns the new context.
Types ¶
type Client ¶
type Client struct {
BaseURL string
Auth config.AuthConfig
HTTPClient *http.Client
Stdout io.Writer // JSON responses go here
Stderr io.Writer // structured errors go here
JQFilter string // --jq filter expression
Paginate bool // auto-paginate GET responses
DryRun bool // output request as JSON, don't execute
Verbose bool // log request/response to stderr
Pretty bool // pretty-print JSON
Fields string // --fields comma-separated field names for GET
CacheTTL time.Duration // --cache duration; 0 means no caching
}
Client is the core HTTP client for jr. It wraps net/http with auth, pagination, jq filtering, and structured error output.
func FromContext ¶
FromContext retrieves the Client stored in ctx. Returns an error if no client was stored.
func (*Client) ApplyAuth ¶ added in v0.4.0
ApplyAuth sets authentication headers on the request according to the client's Auth configuration.
func (*Client) Do ¶
Do executes an HTTP request and returns an exit code. It constructs the URL from BaseURL+path+query, applies auth, handles pagination, jq filtering, and pretty-printing. Errors are written as structured JSON to Stderr.
func (*Client) VerboseLog ¶ added in v0.8.2
VerboseLog writes a structured JSON log entry to stderr when verbose mode is enabled.