config

package
v0.0.0-...-699b668 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	AppName      string `json:"app_name" yaml:"app_name" toml:"app_name" hcl:"app_name"`
	BaseURL      string `json:"base_url" yaml:"base_url" toml:"base_url" hcl:"base_url"`
	Port         int    `json:"port" yaml:"port" toml:"port" hcl:"port"`
	Verbose      bool   `json:"verbose" yaml:"verbose" toml:"verbose" hcl:"verbose"`
	StaticDir    string `json:"static_dir" yaml:"static_dir" toml:"static_dir" hcl:"static_dir"`
	ViewsDir     string `json:"view_dir" yaml:"view_dir" toml:"view_dir" hcl:"view_dir"`
	Database     string `json:"database" yaml:"database" toml:"database" hcl:"database"`
	DatabaseConn string `json:"database_conn" yaml:"database_conn" toml:"database_conn" hcl:"database_conn"`
	Automigrate  bool   `json:"automigrate" yaml:"automigrate" toml:"automigrate" hcl:"automigrate"`
	NoModel      bool   `json:"no_model" yaml:"no_model" toml:"no_model" hcl:"no_model"`

	// session
	SessionName     string `json:"session_name" yaml:"session_name" toml:"session_name" hcl:"session_name"`
	SessionPath     string `json:"session_path" yaml:"session_path" toml:"session_path" hcl:"session_path"`
	SessionDomain   string `json:"session_domain" yaml:"session_domain" toml:"session_domain" hcl:"session_domain"`
	SessionMaxAge   int    `json:"session_max_age" yaml:"session_max_age" toml:"session_max_age" hcl:"session_max_age"`
	SessionSecure   bool   `json:"session_secure" yaml:"session_secure" toml:"session_secure" hcl:"session_secure"`
	SessionHTTPOnly bool   `json:"session_httponly" yaml:"session_httponly" toml:"session_httponly" hcl:"session_httponly"`

	// The name of the session store to use
	// Options are
	// file , cookie ,ql
	SessionStore string `json:"session_store" yaml:"session_store" toml:"session_store" hcl:"session_store"`

	// Flash is the session name for flash messages
	Flash string `json:"flash" yaml:"flash" toml:"flash" hcl:"flash"`

	// KeyPair for secure cookie its a comma separates strings of keys.
	SessionKeyPair []string `json:"session_key_pair" yaml:"session_key_pair" toml:"session_key_pair" hcl:"session_key_pair"`

	// flash message
	FlashContextKey string `json:"flash_context_key" yaml:"flash_context_key" toml:"flash_context_key" hcl:"flash_context_key"`
}

Config stores configurations values

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration settings.

func NewConfig

func NewConfig(path string) (*Config, error)

NewConfig reads configuration from path. The format is deduced from the file extension

  • .json - is decoded as json
  • .yml - is decoded as yaml
  • .toml - is decoded as toml
  • .hcl - is decoded as hcl

func (*Config) SyncEnv

func (c *Config) SyncEnv() error

SyncEnv overrides c field's values that are set in the environment.

The environment variable names are derived from config fields by underscoring, and uppercasing the name. E.g. AppName will have a corresponding environment variable APP_NAME

NOTE only int, string and bool fields are supported and the corresponding values are set. when the field value is not supported it is ignored.

Jump to

Keyboard shortcuts

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