httpclient

package
v0.2.0-alpha.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package httpclient decodes the error envelope the BuildMax server writes.

Every refusal outside the managed gateway comes back from httputil.WriteJSONError as {"error": "..."}, so a client that reports only resp.Status throws away the one sentence saying what went wrong. This is the one reader of that envelope, so no client has to remember to look.

The gateway is deliberately not a caller: it answers llmwire.ErrorResponse, a versioned contract with its own code field, and internal/infra/llmremote decodes it against that contract rather than this one.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UploadFile

func UploadFile(ctx context.Context, client *http.Client, url, token, fieldName, path, filename string) (*http.Response, error)

UploadFile posts one local file as a multipart request and returns the response for the caller to decode and close.

The body is streamed through a pipe rather than buffered: an artifact is whatever size the deployment allows, and a client that had to hold one in memory to send it would make the limit twice as expensive as it looks.

Types

type Error

type Error struct {
	StatusCode int
	Message    string
	// Op names the call, e.g. "worker API GET /api/worker/task-runs/r_1", so
	// the error reads usefully where it surfaces rather than only where it was
	// created.
	Op string
}

Error is a refused HTTP request. Message is what the server said, empty when it said nothing decodable.

func DecodeError

func DecodeError(resp *http.Response, op string) *Error

DecodeError reads the envelope out of a refused response.

It consumes the body, so callers use it only on a status they have already decided is a failure. "message" is accepted alongside "error" because a proxy in front of the server may answer in its own shape.

func (*Error) Error

func (e *Error) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL