MCPcopy
hub / github.com/livebud/bud / Load

Function Load

package/budhttp/client.go:36–56  ·  view source on GitHub ↗

Load a client from an address

(log log.Log, addr string)

Source from the content-addressed store, hash-verified

34
35// Load a client from an address
36func Load(log log.Log, addr string) (Client, error) {
37 url, err := urlx.Parse(addr)
38 if err != nil {
39 return nil, err
40 }
41 transport, err := socket.Transport(addr)
42 if err != nil {
43 return nil, fmt.Errorf("budhttp: unable to create transport from listener. %w", err)
44 }
45 httpClient := &http.Client{
46 Transport: transport,
47 CheckRedirect: func(req *http.Request, via []*http.Request) error {
48 return http.ErrUseLastResponse
49 },
50 }
51 return &client{
52 baseURL: url.String(),
53 httpClient: httpClient,
54 log: log,
55 }, nil
56}
57
58type client struct {
59 baseURL string

Callers 6

TestOpenFunction · 0.92
TestOpen404Function · 0.92
TestEventsFunction · 0.92
TestScriptFunction · 0.92
TestScriptEvalFunction · 0.92
TryFunction · 0.70

Calls 3

ParseFunction · 0.92
TransportFunction · 0.92
StringMethod · 0.65

Tested by 5

TestOpenFunction · 0.74
TestOpen404Function · 0.74
TestEventsFunction · 0.74
TestScriptFunction · 0.74
TestScriptEvalFunction · 0.74