Help us shape the future of Go! Take the 2026 Go Developer Survey

servicehttp

package
v0.45.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0, Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package servicehttp owns signed HTTP exchanges for service clients. Resource discovery, protocol statuses and domain errors belong to callers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client owns connection setup, signing and bounded response reads. Its HTTP client never follows redirects.

func New

func New(endpoint, unixPath string, key sshcert.RawPrivateKey, audience string, cfg tlsconfig.Config) (*Client, error)

New uses unixPath as the endpoint path for Unix sockets; HTTP URLs retain their configured path. The audience identifies the receiving service.

func (*Client) Do

func (c *Client) Do(ctx context.Context, request Request, limit int64) (*Response, error)

Do signs the request, sends it without following redirects, and reads at most limit bytes. ContentType is explicit, including for requests without a body.

func (*Client) Endpoint

func (c *Client) Endpoint() string

Endpoint is the configured HTTP URL, or the local route selected for a socket.

func (*Client) Resolve

func (c *Client) Resolve(raw string) (*url.URL, error)

Resolve resolves a discovered reference against Endpoint and enforces this client's transport policy. Unix references must stay on the local service; HTTP references must satisfy the configured TLS policy.

type Request

type Request struct {
	Method, URL, Actor, ContentType, IfMatch string
	Body                                     []byte
}

Request carries exactly the operation and metadata covered by the signature. URL is a complete target; discovered references must first pass Resolve. Actor is empty for service operations and identifies the public caller otherwise.

type Response

type Response struct {
	Status int
	Header http.Header
	Body   []byte
}

Response owns its buffered body; callers have nothing to close. HTTP failure statuses are responses, leaving their interpretation to each protocol.

Jump to

Keyboard shortcuts

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