MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / NewClientFromURL

Function NewClientFromURL

internal/cli/client.go:41–78  ·  view source on GitHub ↗

NewClientFromURL creates a client from a full base URL (e.g., "https://app.getpad.dev").

(baseURL string)

Source from the content-addressed store, hash-verified

39
40// NewClientFromURL creates a client from a full base URL (e.g., "https://app.getpad.dev").
41func NewClientFromURL(baseURL string) *Client {
42 baseURL = strings.TrimRight(baseURL, "/")
43 c := &Client{
44 baseURL: baseURL + "/api/v1",
45 httpClient: &http.Client{
46 Timeout: 10 * time.Second,
47 },
48 // Long-running transfer client for streaming endpoints
49 // (workspace export bundles in/out, future S3 downloads).
50 // 10s on the default client is the right SLA for normal API
51 // calls but kills a multi-GiB bundle upload mid-stream over
52 // anything but a fast local link. 1 hour is generous enough
53 // for ~100 MB/s uplinks shipping a 350 GiB bundle and still
54 // caps a hung connection eventually. (Codex review on PR
55 // #306 round 2.)
56 streamClient: &http.Client{
57 Timeout: 1 * time.Hour,
58 },
59 }
60
61 // Auto-load credentials for THIS server URL if any are saved. We use
62 // the original baseURL (without the /api/v1 suffix added below) so
63 // the lookup matches what login/save commands key on. Credentials
64 // for other servers are left untouched in the store — see TASK-1228
65 // / IDEA-1226 for the per-server design.
66 if store, err := LoadStore(); err == nil {
67 if creds := store.Get(baseURL); creds != nil {
68 c.authToken = creds.Token
69 }
70 }
71
72 // Auto-load agent name from .pad.toml if available
73 if pt, _ := LoadPadToml(); pt != nil && pt.AgentName != "" {
74 c.agentName = pt.AgentName
75 }
76
77 return c
78}
79
80// SetAuthToken sets the authorization token for API requests.
81func (c *Client) SetAuthToken(token string) {

Callers 15

setupCmdFunction · 0.92
loginCmdFunction · 0.92
logoutCmdFunction · 0.92
whoamiCmdFunction · 0.92
resetPasswordCmdFunction · 0.92
initCmdFunction · 0.92
collectServerInfoFunction · 0.92
completeCollectionNamesFunction · 0.92
padInitCmdFunction · 0.92

Calls 3

LoadStoreFunction · 0.85
LoadPadTomlFunction · 0.85
GetMethod · 0.65