config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const Prefix = "cosmos"

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthConfig

type AuthConfig struct {
	Keys            map[string]string `desc:"a map of key id to key path on disk"`
	Audience        string            `default:"http://localhost:8888" desc:"value for the aud jwt claim"`
	Issuer          string            `default:"http://localhost:8888" desc:"value for the iss jwt claim"`
	CookieDomain    string            `split_words:"true" default:"localhost" desc:"limit the cookies to the specified domain (same as allowed origins)"`
	AccessTokenTTL  time.Duration     `split_words:"true" default:"24h" desc:"the amount of time before an access token expires"`
	RefreshTokenTTL time.Duration     `split_words:"true" default:"48h" desc:"the amount of time before a refresh token expires"`
	TokenOverlap    time.Duration     `split_words:"true" default:"-1h" desc:"the amount of overlap between the access and refresh token"`
}

type Config

type Config struct {
	Maintenance  bool                `default:"false" desc:"sets the server to maintenance mode if true"`
	BindAddr     string              `split_words:"true" default:":8888" desc:"the ip address and port to bind the server to"`
	Mode         string              `default:"release" desc:"one of debug, test, or release"`
	LogLevel     logger.LevelDecoder `split_words:"true" default:"info" desc:"the verbosity of logging"`
	ConsoleLog   bool                `split_words:"true" default:"false" desc:"human readable instead of json logging"`
	AllowOrigins []string            `split_words:"true" default:"http://localhost:8888" desc:"origin of website accessing API"`
	Database     DatabaseConfig      `desc:"database configuration"`
	Auth         AuthConfig          `desc:"authentication and claims issuer configuration"`
	// contains filtered or unexported fields
}

func New

func New() (conf Config, err error)

func (Config) GetLogLevel

func (c Config) GetLogLevel() zerolog.Level

func (Config) IsZero

func (c Config) IsZero() bool

Returns true if the config has not been correctly processed from the environment.

func (Config) Validate

func (c Config) Validate() (err error)

Custom validations are added here, particularly validations that require one or more fields to be processed before the validation occurs. NOTE: ensure that all nested config validation methods are called here.

type DatabaseConfig

type DatabaseConfig struct {
	URL      string `` /* 130-byte string literal not displayed */
	ReadOnly bool   `split_words:"true" default:"false" desc:"open the database in readonly mode"`
	Testing  bool   `default:"false" desc:"if set to true, opens a sql mock rather than an actual db connection"`
}

Jump to

Keyboard shortcuts

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