serviceapi

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 12 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 serviceapi provides an HTTP client for internal LFX service APIs authenticated with OAuth2 client credentials (M2M bearer tokens). These services (e.g., Member Onboarding, LFX Lens) have no per-user authorization — the MCP server enforces access control via the V2 access-check endpoint before proxying requests here.

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 is an HTTP client for an internal service API.

func NewClient

func NewClient(cfg Config) (*Client, error)

NewClient creates a new service API client.

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string, query url.Values) ([]byte, int, error)

Get performs a GET request to the given path with optional query parameters. Returns the response body, HTTP status code, and any error.

func (*Client) PostJSON

func (c *Client) PostJSON(ctx context.Context, path string, body any) ([]byte, int, error)

PostJSON performs a POST request with a JSON body. Returns the response body, HTTP status code, and any error.

func (*Client) PostMultipart

func (c *Client) PostMultipart(ctx context.Context, path string, fields map[string]string) ([]byte, int, error)

PostMultipart performs a POST request with a multipart/form-data body. This is used for AgentOS endpoints that accept multipart form submissions. Returns the response body, HTTP status code, and any error.

type Config

type Config struct {
	// BaseURL is the root URL of the service API (e.g., "https://onboarding.lfx.internal").
	BaseURL string

	// TokenSource provides bearer tokens for request authentication.
	TokenSource TokenSource

	// HTTPClient is the HTTP client to use. If nil, a default client with 30s
	// timeout is created.
	HTTPClient *http.Client

	// DebugLogger enables wire-level request/response logging when non-nil.
	DebugLogger *slog.Logger
}

Config holds configuration for a service API client.

type TokenSource

type TokenSource interface {
	GetToken(ctx context.Context) (string, error)
}

TokenSource provides bearer tokens for authenticating requests to service APIs.

Jump to

Keyboard shortcuts

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