apiclient

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package apiclient talks to the API of a locally running roji server.

Requests connect to an address the server listens on and carry the dashboard hostname in the Host header. That avoids depending on *.localhost DNS resolution while still reaching the dashboard virtual host, which is the only one that serves the /_api endpoints.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(settings *config.Settings, path string, timeout time.Duration) (*http.Response, error)

Get sends a GET request to the local roji API endpoint at path. The caller is responsible for closing the response body.

func NewClient

func NewClient(timeout time.Duration) *http.Client

NewClient returns an HTTP client for talking to the local roji server. TLS verification is disabled because roji serves a self-signed certificate.

Verifying against roji's own CA was considered and left out. The connection is to an address on this machine (loopback unless bind says otherwise) and carries no secrets, while verification would break the CLI whenever the certificate does not cover the dashboard hostname, has expired, or the CA is not readable by the user running the CLI.

func NewRequest

func NewRequest(settings *config.Settings, path string) (*http.Request, error)

NewRequest builds a GET request against the local roji API endpoint at path, using the resolved settings for the listen address and the dashboard hostname.

func SendJSON added in v1.4.0

func SendJSON(ctx context.Context, client *http.Client, settings *config.Settings, method, path string, payload any) (*http.Response, error)

SendJSON sends a request with an optional JSON body to the local roji API endpoint at path, through client. A nil payload sends no body. The caller is responsible for closing the response body.

The client is the caller's so that one making many requests — `roji run` renewing its route — can keep a connection open instead of making a new one, TLS handshake included, every time.

Types

This section is empty.

Jump to

Keyboard shortcuts

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