client

package
v1.136.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package client implements HTTP API tools with a caller-supplied template expander.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateToolSet

func CreateToolSet[E Expander](toolset latest.Toolset, runConfig *config.RuntimeConfig, newExpander func(environment.Provider) E, options ...Option) (tools.ToolSet, error)

CreateToolSet builds a configured HTTP tool with the supplied expander.

func Creator

func Creator[E Expander](newExpander func(environment.Provider) E, options ...Option) func(context.Context, latest.Toolset, string, *config.RuntimeConfig, string) (tools.ToolSet, error)

Creator returns a teamloader.ToolsetCreator using the supplied expander. Pass teamloader.NewEnvExpander to support placeholders without JavaScript.

Types

type Expander

type Expander interface {
	Expand(ctx context.Context, text string, values map[string]string) string
	ExpandMap(ctx context.Context, values map[string]string) map[string]string
}

Expander resolves endpoint and header templates at request time. Both js.Expander and teamloader.NewEnvExpander satisfy this interface.

type Option

type Option func(*ToolSet)

Option configures an api ToolSet.

func WithAllowPrivateIPs

func WithAllowPrivateIPs(allow bool) Option

WithAllowPrivateIPs disables SSRF dial-time protection so the api tool may dial loopback / RFC1918 / link-local addresses. Operators opt in via `allow_private_ips: true` when the configured endpoint legitimately targets internal services. Tests use this to talk to httptest.NewServer.

func WithHeaderResolver

func WithHeaderResolver(resolve func(context.Context, map[string]string) map[string]string) Option

WithHeaderResolver resolves headers after template expansion on every request. Pass upstream.ResolveHeaders to enable upstream JavaScript header templates.

func WithTimeout

func WithTimeout(d time.Duration) Option

WithTimeout overrides the default HTTP client timeout (see httpclient.DefaultToolHTTPTimeout).

type ToolSet

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

func New

func New(apiConfig latest.APIToolConfig, expander Expander, opts ...Option) *ToolSet

func (*ToolSet) Instructions

func (t *ToolSet) Instructions() string

func (*ToolSet) Tools

func (t *ToolSet) Tools(context.Context) ([]tools.Tool, error)

Jump to

Keyboard shortcuts

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