api

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package api is the HTTP client for the Checkend API. It maps HTTP errors to exit codes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OrNotFound

func OrNotFound(raw json.RawMessage, err error, msg, hint string) (json.RawMessage, error)

OrNotFound replaces a 404 with the given message and hint.

Types

type Client

type Client struct {
	URL string
	// contains filtered or unexported fields
}

Client calls one Checkend instance.

func New

func New(h *host.Host, baseURL, token string) *Client

New returns a client. The token can be empty (only /health needs no token).

func (*Client) Call

func (c *Client) Call(method, path string, body []byte, contentType string) (json.RawMessage, error)

Call sends a request with the token and returns the JSON body of a 2xx response.

func (*Client) Delete

func (c *Client) Delete(path string) (json.RawMessage, error)

Delete calls DELETE path.

func (*Client) Get

func (c *Client) Get(path string, query map[string]string) (json.RawMessage, error)

Get calls GET path?query. Empty query values are left out.

func (*Client) Health

func (c *Client) Health() (Health, json.RawMessage, error)

Health calls GET /health. It needs no token. A 503 still has a health body.

func (*Client) Post

func (c *Client) Post(path string, body any) (json.RawMessage, error)

Post calls POST path with a JSON body.

func (*Client) PostRaw

func (c *Client) PostRaw(path string, body []byte, accept string) (int, string, []byte, error)

PostRaw sends a POST with the token and returns the status, the content type and the body, for protocols that are not the JSON API (MCP). It follows no redirects.

func (*Client) Text

func (c *Client) Text(path string) (string, error)

Text calls GET path without the token and returns the body as text (for example a Markdown recipe). It reads at most 1 MB.

type Health

type Health struct {
	Status  string `json:"status"`
	Version any    `json:"version"`
	Ingest  *struct {
		Mode any `json:"mode"`
	} `json:"ingest"`
}

Health is the body of GET /health.

type NotFound

type NotFound struct{ Code string }

NotFound is a 404. Code is the "error" of the body, for example "project_not_found".

func (*NotFound) Error

func (e *NotFound) Error() string

func (*NotFound) Unwrap

func (e *NotFound) Unwrap() error

Unwrap gives the CLI error with exit code 3.

Jump to

Keyboard shortcuts

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