hyper

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package hyper provides a fantasy.Provider that proxies requests to Hyper.

Index

Constants

View Source
const (
	// Name is the default name of this meta provider.
	Name = "hyper"
)

Variables

View Source
var BaseURL = sync.OnceValue(func() string {
	return cmp.Or(os.Getenv("HYPER_URL"), defaultBaseURL)
})

BaseURL returns the base URL, which is either $HYPER_URL or the default.

View Source
var Embedded = sync.OnceValue(func() catwalk.Provider {
	var provider catwalk.Provider
	if err := json.Unmarshal(embedded, &provider); err != nil {
		slog.Error("could not use embedded provider data", "err", err)
	}
	return provider
})

Embedded returns the embedded Hyper provider.

View Source
var Enabled = sync.OnceValue(func() bool {
	b, _ := strconv.ParseBool(
		cmp.Or(
			os.Getenv("HYPER"),
			os.Getenv("HYPERCRUSH"),
			os.Getenv("HYPER_ENABLE"),
			os.Getenv("HYPER_ENABLED"),
		),
	)
	return b
})

Enabled returns true if hyper is enabled.

View Source
var ErrNoCredits = errors.New("you're out of credits")

Functions

func New

func New(opts ...Option) (fantasy.Provider, error)

New creates a new proxy provider.

Types

type Option

type Option = func(*options)

Option configures the proxy provider.

func WithAPIKey

func WithAPIKey(key string) Option

WithAPIKey sets the API key.

func WithBaseURL

func WithBaseURL(url string) Option

WithBaseURL sets the proxy base URL (e.g. http://localhost:8080).

func WithHTTPClient

func WithHTTPClient(c *http.Client) Option

WithHTTPClient sets custom HTTP client.

func WithHeaders

func WithHeaders(headers map[string]string) Option

WithHeaders sets extra headers sent to the proxy.

func WithName

func WithName(name string) Option

WithName sets the provider name.

Jump to

Keyboard shortcuts

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