config

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package config turns a Config file into the Upstream definitions it declares.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(data []byte, lookupEnv LookupEnv) ([]Upstream, []Warning, error)

Parse parses Config bytes into the Upstreams to start, in Config order, plus warnings about the Config. lookupEnv resolves ${VAR} references.

func Path

func Path(flag string, lookupEnv LookupEnv) (string, error)

Path resolves which Config file to read: flag (from -c/--config), then $SPRUT_CONFIG, then $XDG_CONFIG_HOME/sprut/config.json, then ~/.config/sprut/config.json.

Types

type LookupEnv

type LookupEnv func(string) (string, bool)

LookupEnv looks up an environment variable, like os.LookupEnv.

func LookupIn

func LookupIn(env []string) LookupEnv

LookupIn returns a lookup over env, which is in os.Environ form. As with a real environment, the last entry for a key wins.

type Transport

type Transport string

Transport is how the Gateway talks to an Upstream.

const (
	Stdio Transport = "stdio"
	HTTP  Transport = "http"
)

type Upstream

type Upstream struct {
	Name      string
	Transport Transport

	// stdio
	Command string
	Args    []string
	Env     map[string]string // layered on top of the inherited environment

	// HTTP
	URL     string
	Headers map[string]string
}

Upstream is one resolved Upstream definition from the Config.

type Warning

type Warning struct {
	Upstream string
	Message  string
}

Warning is a problem in the Config that does not stop the Gateway.

Jump to

Keyboard shortcuts

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