transport

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2025 License: AGPL-3.0 Imports: 8 Imported by: 0

README

transport

Internal package transport provides HTTP client utilities and transport layers.

transport

import "github.com/agentstation/starmap/internal/transport"

Index

Variables

DefaultHTTPTimeout is the default timeout for HTTP requests.

var DefaultHTTPTimeout = constants.DefaultHTTPTimeout

func DecodeResponse

func DecodeResponse(resp *http.Response, target any) error

DecodeResponse decodes a JSON response into the target structure.

type Authenticator

Authenticator applies authentication to HTTP requests.

type Authenticator interface {
    Apply(req *http.Request, apiKey string)
}

type BearerAuth

BearerAuth implements Bearer token authentication.

type BearerAuth struct{}

func (*BearerAuth) Apply
func (a *BearerAuth) Apply(req *http.Request, apiKey string)

Apply implements the Authenticator interface for BearerAuth.

type Client

Client provides HTTP client functionality with authentication.

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

func New
func New(provider *catalogs.Provider) *Client

New creates a new transport client with the specified authenticator.

func (*Client) Do
func (c *Client) Do(req *http.Request, provider *catalogs.Provider) (*http.Response, error)

Do performs an HTTP request with authentication applied.

func (*Client) DoWithContext
func (c *Client) DoWithContext(ctx context.Context, req *http.Request, provider *catalogs.Provider) (*http.Response, error)

DoWithContext performs an HTTP request with authentication applied and context support. The provided context will be used for the request, overriding any existing context in req.

func (*Client) Get
func (c *Client) Get(ctx context.Context, url string, provider *catalogs.Provider) (*http.Response, error)

Get performs a GET request.

type HeaderAuth

HeaderAuth implements custom header authentication.

type HeaderAuth struct {
    Header string
}

func (*HeaderAuth) Apply
func (a *HeaderAuth) Apply(req *http.Request, apiKey string)

Apply implements the Authenticator interface for HeaderAuth.

type NoAuth

NoAuth implements no authentication.

type NoAuth struct{}

func (*NoAuth) Apply
func (a *NoAuth) Apply(_ *http.Request, _ string)

Apply implements the Authenticator interface for NoAuth.

type ProviderAuth

ProviderAuth implements provider-specific authentication using catalog configuration.

type ProviderAuth struct {
    Provider *catalogs.Provider
}

func (*ProviderAuth) Apply
func (a *ProviderAuth) Apply(req *http.Request, apiKey string)

Apply implements the Authenticator interface for ProviderAuth.

type QueryAuth

QueryAuth implements API key as query parameter authentication.

type QueryAuth struct {
    Param string
}

func (*QueryAuth) Apply
func (a *QueryAuth) Apply(req *http.Request, apiKey string)

Apply implements the Authenticator interface for QueryAuth.

type RequestBuilder

RequestBuilder helps build HTTP requests with provider-specific configurations.

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

func NewRequestBuilder
func NewRequestBuilder(provider *catalogs.Provider) *RequestBuilder

NewRequestBuilder creates a new request builder for a provider.

func (*RequestBuilder) AddProviderHeaders
func (rb *RequestBuilder) AddProviderHeaders(req *http.Request)

AddProviderHeaders adds provider-specific headers to a request.

func (*RequestBuilder) GetBaseURL
func (rb *RequestBuilder) GetBaseURL() string

GetBaseURL returns the base URL for API requests.

func (*RequestBuilder) GetModelsURL
func (rb *RequestBuilder) GetModelsURL(defaultURL string) string

GetModelsURL returns the URL for listing models.

Generated by gomarkdoc

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultHTTPTimeout = constants.DefaultHTTPTimeout

DefaultHTTPTimeout is the default timeout for HTTP requests.

Functions

func DecodeResponse

func DecodeResponse(resp *http.Response, target any) error

DecodeResponse decodes a JSON response into the target structure.

Types

type Authenticator

type Authenticator interface {
	Apply(req *http.Request, apiKey string)
}

Authenticator applies authentication to HTTP requests.

type BearerAuth

type BearerAuth struct{}

BearerAuth implements Bearer token authentication.

func (*BearerAuth) Apply

func (a *BearerAuth) Apply(req *http.Request, apiKey string)

Apply implements the Authenticator interface for BearerAuth.

type Client

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

Client provides HTTP client functionality with authentication.

func New

func New(provider *catalogs.Provider) *Client

New creates a new transport client with the specified authenticator.

func (*Client) Do

func (c *Client) Do(req *http.Request, provider *catalogs.Provider) (*http.Response, error)

Do performs an HTTP request with authentication applied.

func (*Client) DoWithContext

func (c *Client) DoWithContext(ctx context.Context, req *http.Request, provider *catalogs.Provider) (*http.Response, error)

DoWithContext performs an HTTP request with authentication applied and context support. The provided context will be used for the request, overriding any existing context in req.

func (*Client) Get

func (c *Client) Get(ctx context.Context, url string, provider *catalogs.Provider) (*http.Response, error)

Get performs a GET request.

type HeaderAuth

type HeaderAuth struct {
	Header string
}

HeaderAuth implements custom header authentication.

func (*HeaderAuth) Apply

func (a *HeaderAuth) Apply(req *http.Request, apiKey string)

Apply implements the Authenticator interface for HeaderAuth.

type NoAuth

type NoAuth struct{}

NoAuth implements no authentication.

func (*NoAuth) Apply

func (a *NoAuth) Apply(_ *http.Request, _ string)

Apply implements the Authenticator interface for NoAuth.

type ProviderAuth

type ProviderAuth struct {
	Provider *catalogs.Provider
}

ProviderAuth implements provider-specific authentication using catalog configuration.

func (*ProviderAuth) Apply

func (a *ProviderAuth) Apply(req *http.Request, apiKey string)

Apply implements the Authenticator interface for ProviderAuth.

type QueryAuth

type QueryAuth struct {
	Param string
}

QueryAuth implements API key as query parameter authentication.

func (*QueryAuth) Apply

func (a *QueryAuth) Apply(req *http.Request, apiKey string)

Apply implements the Authenticator interface for QueryAuth.

type RequestBuilder

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

RequestBuilder helps build HTTP requests with provider-specific configurations.

func NewRequestBuilder

func NewRequestBuilder(provider *catalogs.Provider) *RequestBuilder

NewRequestBuilder creates a new request builder for a provider.

func (*RequestBuilder) AddProviderHeaders

func (rb *RequestBuilder) AddProviderHeaders(req *http.Request)

AddProviderHeaders adds provider-specific headers to a request.

func (*RequestBuilder) GetBaseURL

func (rb *RequestBuilder) GetBaseURL() string

GetBaseURL returns the base URL for API requests.

func (*RequestBuilder) GetModelsURL

func (rb *RequestBuilder) GetModelsURL(defaultURL string) string

GetModelsURL returns the URL for listing models.

Jump to

Keyboard shortcuts

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