config

package
v0.0.0-...-11149d6 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package config is defined application settings.

Index

Constants

This section is empty.

Variables

View Source
var DefaultFakeTime = time.Date(2023, 1, 1, 12, 0, 0, 0, time.UTC)

DefaultFakeTime 時刻偽装モードのデフォルトの初期時刻。

Functions

This section is empty.

Types

type ClientOrigin

type ClientOrigin []string

ClientOrigin indicates the setting of the client origin.

type Config

type Config struct {
	// Port ポート
	// 0 が指定された場合は動的にポートを割り当てる。
	Port uint16 `env:"PORT" envDefault:"8080"`

	// DBHost データベースホスト
	DBHost string `env:"DB_HOST" envDefault:"localhost"`
	// DBPort データベースポート
	DBPort uint16 `env:"DB_PORT" envDefault:"3306"`
	// DBName データベース名
	DBName string `env:"DB_NAME,required"`
	// DBUsername データベースユーザー名
	DBUsername string `env:"DB_USERNAME,required"`
	// DBPassword データベースパスワード
	DBPassword string `env:"DB_PASSWORD"`
	DBUrl      string `env:"DB_URL,required"`

	// Redis connection
	RedisHost     string `env:"REDIS_HOST" envDefault:"localhost"`
	RedisPort     uint16 `env:"REDIS_PORT" envDefault:"6379"`
	RedisDB       int    `env:"REDIS_DB" envDefault:"0"`
	RedisPassword string `env:"REDIS_PASSWORD"`

	// AuthSecret 認証トークンの署名用シークレット
	AuthSecret   string `env:"AUTH_SECRET,required"`
	SecretIssuer string `env:"SECRET_ISSUER,required"`

	// ClientOrigin クライアントのオリジン
	ClientOrigin ClientOrigin `env:"CLIENT_ORIGIN"`

	// DebugCORS CORS デバッグモード
	DebugCORS bool `env:"DEBUG_CORS"`

	AppDebug bool `env:"APP_DEBUG"`
	// development, staging, production
	AppEnv EnvironmentMode `env:"APP_ENV" envDefault:"production"`
	// FakeTime Fake time mode setting
	// If a time is specified, fix to that time.
	// If a truthy value is specified, fix to the default time.
	FakeTime FakeTimeMode `env:"FAKE_TIME"`
	LogLevel LogLevel     `env:"LOG_LEVEL,required"`

	CORSMaxAge           int `env:"CORS_MAX_AGE" envDefault:"3600"`
	ThrottleRequestLimit int `env:"THROTTLE_REQUEST_LIMIT" envDefault:"100"`
}

Config アプリケーション設定を表す構造体。

func Get

func Get() (*Config, error)

Get Get application settings from environment variables.

type EnvironmentMode

type EnvironmentMode string

EnvironmentMode Indicates the setting of the environment mode that can be specified.

const (
	// ProductionEnv Indicates production environment mode.
	ProductionEnv EnvironmentMode = "production"
	// StagingEnv Indicates staging environment mode.
	StagingEnv EnvironmentMode = "staging"
	// TestEnv Indicates the test environment mode.
	TestEnv EnvironmentMode = "test"
	// DevelopmentEnv Indicates development (local) environment mode.
	DevelopmentEnv EnvironmentMode = "development"
)

type FakeTimeMode

type FakeTimeMode struct {
	// Enabled true のとき有効
	Enabled bool
	// Time 初期時刻
	Time time.Time
}

FakeTimeMode 時刻偽装モードの設定を表す。

type LogLevel

type LogLevel string

LogLevel Indicates the log level setting that can be specified.

const (
	// DebugLevel Indicates the debug log level.
	DebugLevel LogLevel = "debug"
	// InfoLevel Indicates the info log level.
	InfoLevel LogLevel = "info"
	// WarnLevel Indicates the warn log level.
	WarnLevel LogLevel = "warn"
	// ErrorLevel Indicates the error log level.
	ErrorLevel LogLevel = "error"
	// CriticalLevel Indicates the critical log level.
	CriticalLevel LogLevel = "critical"
)

Jump to

Keyboard shortcuts

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