config

package
v0.0.0-...-f46f3e0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthConfig

type AuthConfig struct {
	// Client ID for Google OAuth.
	GoogleOAuth2ClientID string
	// Client secret for Google OAuth.
	GoogleOAuth2ClientSecret string
}

Settings and other values that affect how the server should perform user authentication.

type Config

type Config struct {
	// Settings and other values that affect how the server should perform user
	// authentication.
	Auth AuthConfig
	// Broadly describes the circumstances under which the server is running.
	Environment Environment
	// Port over which HTTP requests should be serviced.
	HttpPort int
	// URL of the home page.
	HomeUrl string
	// Settings and other values that affect how the server should send emails.
	Mail MailConfig
	// Settings and other values that affect how the server should interface with
	// Postgres.
	Postgres PostgresConfig
	// Settings and other values that affect how the server should interface with
	// Redis.
	Redis RedisConfig
}

Settings and other values that affect how the server should function.

func New

func New() (*Config, error)

Reads Config from the environment and command line arguments.

func (*Config) ForCors

func (c *Config) ForCors() cors.Options

Returns CORS configuration for the HTTP server.

func (*Config) ForGorm

func (c *Config) ForGorm() *gorm.Config

Returns a configuration struct for Gorm.

func (*Config) ForGormPostgresDriver

func (c *Config) ForGormPostgresDriver() string

Returns a DSN for connecting Gorm to Postgres.

func (*Config) ForRedis

func (c *Config) ForRedis() *redis.Options

Returns a configuration struct for Redis.

func (*Config) ForSessionStore

func (c *Config) ForSessionStore() sessions.Options

Returns a configuration struct for Fiber's session middleware that leans on the specified storage to keep track of cookies internally.

func (*Config) PublicBaseUrl

func (c *Config) PublicBaseUrl() string

Returns the base URL that external clients will use to reach this server over HTTP(s).

type Environment

type Environment int

Broadly describes the circumstances under which the server is running.

const (
	// Environment used during local development.
	DevEnvironment Environment = iota
	// Environment used when deployed into a production setting.
	ProdEnvironment
)

type MailConfig

type MailConfig struct {
	// Network address of the SMTP server.
	Host string
	// Password of the server's SMTP user.
	Password string
	// TCP port used for SMTP.
	Port int
	// Name of the server's SMTP user.
	User string
	// User-friendly name of the server's email sender.
	UserName string
}

Settings and other values that affect how the server should send emails.

type PostgresConfig

type PostgresConfig struct {
	// Name of the server's Postgres database.
	DatabaseName string
	// Network address of Postgres.
	Host string
	// Password of the server's Postgres user.
	Password string
	// TCP port of Postgres.
	Port int
	// Name of the server's Postgres user.
	User string
}

Settings and other values that affect how the server should interface with Postgres.

type RedisConfig

type RedisConfig struct {
	// Network address of Redis.
	Host string
	// Password of the server's Redis user.
	Password string
	// TCP port of Redis.
	Port int
}

Settings and other values that affect how the server should interface with Redis.

Jump to

Keyboard shortcuts

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