Documentation
¶
Overview ¶
Package forgedashboard is a client for the forge-dashboard REST API (github.com/alrayyes/forge-dashboard).
Authenticate with a personal API token, generated from the dashboard's own Settings page (POST /api/tokens) -- the alternative forge-dashboard's spec documents to its browser session cookie, and the one this SDK actually uses, since a headless client has no WebAuthn ceremony to run. Pass the token to New or set FORGE_DASHBOARD_TOKEN.
Package forgedashboard is the official Go SDK for forge-dashboard.
Index ¶
Constants ¶
const TokenEnvVar = "FORGE_DASHBOARD_TOKEN"
TokenEnvVar is the environment variable New falls back to when no token is passed explicitly via WithToken.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
APIError is returned by DecodeError for any forge-dashboard response carrying an error body -- every 4xx/5xx in the spec shares the same {error} shape (components.schemas.Error).
func DecodeError ¶
DecodeError builds an *APIError from a generated response's status and body, or returns nil when statusCode isn't an error. Every operation's generated response type carries these two fields under the same names (StatusCode via HTTPResponse, and Body), so this one helper covers all of them:
resp, err := client.GetDashboardWithResponse(ctx, nil)
if err != nil {
return err // transport failure, already retried
}
if apiErr := forgedashboard.DecodeError(resp.HTTPResponse.StatusCode, resp.Body); apiErr != nil {
return apiErr
}
type Client ¶
type Client struct {
*genclient.ClientWithResponses
}
Client is a forge-dashboard API client. Construct one with New.
type Option ¶
type Option func(*config)
Option configures a Client constructed by New.
func WithHTTPClient ¶
func WithHTTPClient(hc genclient.HttpRequestDoer) Option
WithHTTPClient replaces the underlying HTTP client. The retry transport (WithRetry) wraps whatever Transport this client has set, so pass a client with a custom Transport already configured (proxies, mTLS, ...) rather than replacing RoundTrip yourself afterward.