Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Default = Config{ Cookie: DefaultCookie, Port: 8080, StaticURL: "/static/", Metadata: Metadata{}, }
Default is a basic configuration with insecure values. It will return the Address localhost:8080
var DefaultCookie = CookieConfig{ Age: 14 * 24 * time.Hour, Domain: "", HttpOnly: false, Name: "sessionid", Path: "/", Secure: false, }
DefaultCookie is a default CookieConfig implementation. It expires after two weeks and is not very secure.
Functions ¶
func ParseGooseYAML ¶
func ParseGooseYAML(path string) (conf map[string]DatabaseConfig, err error)
ParseGooseYAML will parse the entire goose database configuration file.
Types ¶
type Config ¶
type Config struct { HTTPS bool `json:"https"` Domain string `json:"domain"` ProxyDomain string `json:"proxy_domain"` Port int `json:"port"` ProxyPort int `json:"proxy_port"` TemplateDir string `json:"templates"` AbsPath string `json:"abs_path"` MediaDir string `json:"media"` MediaURL string `json:"media_url"` StaticDir string `json:"static"` StaticURL string `json:"static_url"` SecretKey string `json:"secret_key"` Database DatabaseConfig `json:"database"` Cookie CookieConfig `json:"cookie"` SMTP SMTPConfig `json:"smtp"` Metadata Metadata `json:"metadata"` }
Config is the parent configuration struct and includes fields for single configurations of a database, cookie, and SMTP connection.
func DefaultConfig ¶
DefaultConfig will return a basic configuration with insecure values. It allows the specification of a secret key.
func (Config) FullAddress ¶
FullAddress returns the scheme, domain, port, and host
type CookieConfig ¶
type CookieConfig struct { Age time.Duration `json:"age"` Domain string `json:"domain"` HttpOnly bool `json:"http_only"` Name string `json:"name"` Path string `json:"path"` Secure bool `json:"secure"` }
CookieConfig contains the fields needed to set and retrieve cookies. Cookie names are valid tokens as defined by RFC 2616 section 2.2: http://tools.ietf.org/html/rfc2616#section-2.2 TL;DR: Any non-control or non-separator character.
type DatabaseConfig ¶
type DatabaseConfig struct { Driver string `json:"driver"` Host string `json:"host"` Port int64 `json:"port"` Name string `json:"name"` User string `json:"user"` Password string `json:"password"` SSLMode string `json:"ssl_mode"` }
DatabaseConfig contains the fields needed to connect to a database.
func ParseDatabaseFile ¶
func ParseDatabaseFile(filepath string) (c DatabaseConfig, err error)
ParseDatabaseFile will create a DatabaseConfig using the given filepath.
func ParseGooseDatabase ¶
func ParseGooseDatabase(path, name string) (c DatabaseConfig, err error)
ParseGooseDatabase will parse a specific database name in the goose configuration file.
func (DatabaseConfig) Credentials ¶
func (db DatabaseConfig) Credentials() string
Credentials with return a string of credentials appropriate for Go's sql.Open function
type GooseConfig ¶
GooseConfig is a representation of database configurations for the goose migration tool: https://bitbucket.org/liamstask/goose
type Metadata ¶
Metadata holds arbitrary strings as key - value pairs
func (Metadata) Get ¶
Get returns the value of the given key. If the key does not exist in the metadata, a blank string will be returned
type SMTPConfig ¶
type SMTPConfig struct { Port int64 `json:"port"` User string `json:"user"` Password string `json:"password"` Host string `json:"host"` From string `json:"from"` Alias string `json:"alias"` }
SMTPConfig contains the fields needed to connect to a SMTP server.
func (SMTPConfig) Address ¶
func (c SMTPConfig) Address() string
Address will return a string of the host and port separated by a colon.
func (SMTPConfig) FromAddress ¶
func (c SMTPConfig) FromAddress() string
FromAddress creates a string suitable for use in an Email's From header.