config

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package config discovers and resolves .blip.toml.

Index

Constants

View Source
const DefaultTimeout = 30 * time.Second

DefaultTimeout applies when an environment does not set one.

Variables

View Source
var ErrNotFound = errors.New("no .blip.toml found in this directory or any parent; run \"blip init <base-url>\" to create one")

ErrNotFound means no config file exists between cwd and the filesystem root.

View Source
var Names = []string{".blip.toml", "blip.toml"}

Names blip looks for, in order, at each level of the walk up from cwd.

Functions

func Discover

func Discover(start string) (string, error)

Discover walks up from start looking for a config file. The first hit wins.

func IsLocalHost

func IsLocalHost(host string) bool

IsLocalHost reports whether a host is loopback, and so whether relaxing TLS against it is a local development concern rather than a real exposure.

Types

type Config

type Config struct {
	File
	Path string
	Root string
}

Config is a parsed file plus where it was found.

func Load

func Load(path string) (*Config, error)

Load reads and validates a config file.

func LoadFrom

func LoadFrom(dir string) (*Config, error)

LoadFrom discovers a config starting at dir and loads it.

func (*Config) EnvNames

func (c *Config) EnvNames() []string

EnvNames lists the defined environments in a stable order.

func (*Config) ResolveEnv

func (c *Config) ResolveEnv(explicit string) (*Environment, error)

ResolveEnv picks an environment: explicit flag, then BLIP_ENV, then default_env, then the sole environment if there is exactly one.

type Env

type Env struct {
	BaseURL    string `toml:"base_url"`
	SpecURL    string `toml:"spec_url"`
	Insecure   bool   `toml:"insecure"`
	Auth       string `toml:"auth"`
	Timeout    string `toml:"timeout"`
	Readonly   bool   `toml:"readonly"`
	ClientCert string `toml:"client_cert"`
	ClientKey  string `toml:"client_key"`
}

Env is one environment block as written in the file.

type Environment

type Environment struct {
	Name       string
	BaseURL    *url.URL
	SpecURL    string
	Insecure   bool
	Auth       string
	Timeout    time.Duration
	Readonly   bool
	ClientCert string
	ClientKey  string
}

Environment is a validated environment, ready to make requests against.

type File

type File struct {
	Name       string         `toml:"name"`
	DefaultEnv string         `toml:"default_env"`
	Envs       map[string]Env `toml:"env"`
	Routes     []Route        `toml:"route"`
}

File mirrors the TOML document.

type Route

type Route struct {
	Name    string `toml:"name"`
	Method  string `toml:"method"`
	Path    string `toml:"path"`
	Summary string `toml:"summary"`
	Group   string `toml:"group"`
}

Route is a hand-declared endpoint, for APIs with no spec.

Jump to

Keyboard shortcuts

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