config

package
v0.0.0-...-9d982d4 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2020 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	Server            *Server  `environment:"SERVER"`
	Storage           *Storage `environment:"STORAGE"`
	Hash              *Hash    `environment:"HASH"`
	JwtPrivateKeyPath string   `environment:"JWT_PRIVATE_KEY_PATH"`
}

Configuration stores all the application config.

func Defaults

func Defaults() Configuration

Defaults returns a Configuration with all the default options. This ignores environment variable values.

func MustParse

func MustParse() Configuration

MustParse wraps Parse, but prints the errors and exits rather than returning them.

func Parse

func Parse() (Configuration, error)

Parse loads the app config using Viper. It logs all the values before returning, and panics on validation errors.

func (*Configuration) JwtPrivateKey

func (cfg *Configuration) JwtPrivateKey() (*ecdsa.PrivateKey, error)

JwtPrivateKey returns the PrivateKey object from the file at the given path. This can be used to sign JWTs in the app.

type Hash

type Hash struct {
	Time        uint32 `environment:"ITERATIONS"`
	Memory      uint32 `environment:"MEMORY_BYTES"`
	Parallelism uint8  `environment:"PARALLELISM"`
	SaltLength  uint8  `environment:"SALT_LENGTH"`
	KeyLength   uint32 `environment:"KEY_LENGTH"`
}

Hash configures the hashing algorithm used to store passwords. This project hashes with Argon2: https://www.alexedwards.net/blog/how-to-hash-and-verify-passwords-with-argon2-in-go

type Postgres

type Postgres struct {
	Database string `environment:"DBNAME"`
	Host     string `environment:"HOST"`
	Port     int    `environment:"PORT"`
	User     string `environment:"USER"`
	Password string `environment:"PASSWORD"`
}

Postgres configures the Postgres connection. These options come from https://godoc.org/github.com/lib/pq#hdr-Connection_String_Parameters

type SSL

type SSL struct {
	CertPath string `environment:"CERT_PATH"`
	KeyPath  string `environment:"KEY_PATH"`
}

SSL stores paths the the cert/key files

type Server

type Server struct {
	Addr                    string `environment:"ADDR"`
	ReadHeaderTimeoutMillis int    `environment:"READ_HEADER_TIMEOUT_MILLIS"`
	SSL                     *SSL   `environment:"SSL"`
}

Server has all the config values which affect the http.Server which responds to requests.

func (*Server) ReadHeaderTimeout

func (cfg *Server) ReadHeaderTimeout() time.Duration

ReadHeaderTimeout returns the time the server will wait for the client to send the HTTP headers before it just times out the request.

type Storage

type Storage struct {
	Postgres *Postgres `environment:"POSTGRES"`
}

Storage has all the config values related to the backend which is used to save accounts info.

Jump to

Keyboard shortcuts

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