config

package
v0.0.0-...-1db7b98 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package config generates an application config object from the environment.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// The name of the application.
	AppName string `split_words:"true" required:"true"`

	// A comma-separated list of allow origins for CORS requests.
	CORSAllowedOrigins string `envconfig:"REALWORLD_CORS_ALLOWED_ORIGINS" split_words:"true" required:"true"`

	// The path to the directory containing runtime data, such as the DB file
	// and encryption keys.
	DataDir string `envconfig:"REALWORLD_DATA_MOUNT" split_words:"true" required:"true"`

	// The database server hostname.
	DBHost string `split_words:"true" required:"true"`

	// The database password.
	DBPassword string `split_words:"true" required:"true"`

	// The database server port.
	DBPort string `split_words:"true" required:"true"`

	// The database to connect to.
	DBName string `split_words:"true" required:"true"`

	// The SSL mode for database connections.
	DbSslMode string `split_words:"true" required:"true"`

	// The database username.
	DBUser string `split_words:"true" required:"true"`

	// Enables stack tracing by panic recovery middleware.
	EnableStackTrace bool `split_words:"true" required:"true"`

	// The server host.
	Host string `split_words:"true" required:"true"`

	// The port to listen on.
	Port string `split_words:"true" required:"true"`

	// The URL to be used as the issuer of JWTs signed by the server.
	JwtIssuer string `split_words:"true" required:"true"`

	// The name of the RSA private key PEM file used to generate JWTs.
	JwtRSAPrivateKeyPEMBasename string `envconfig:"REALWORLD_JWT_RSA_PRIVATE_KEY_PEM_BASENAME" split_words:"true" required:"true"`

	// The lifetime of JWTs issued by the server.
	JwtTTL time.Duration `envconfig:"REALWORLD_JWT_TTL" required:"true"`

	// The read timeout for incoming requests to the server.
	ReadTimeout time.Duration `split_words:"true" required:"true"`

	// The write timeout for outgoing responses from the server.
	WriteTimeout time.Duration `split_words:"true" required:"true"`
	// contains filtered or unexported fields
}

Config represents the complete configuration settings for the application.

func New

func New() (Config, error)

New attempts to parse a `Config` object from the environment.

func (*Config) JWTPrivateKey

func (c *Config) JWTPrivateKey() *rsa.PrivateKey

JWTPrivateKey parses the RSA private key PEM loaded from the environment into a private key object.

func (*Config) ServerAddress

func (c *Config) ServerAddress() string

ServerAddress returns the address the server should listen on.

Jump to

Keyboard shortcuts

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