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 = Cookie{ 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 ¶
This section is empty.
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"`
Version string `json:"version"`
Database Database `json:"database"`
Cookie Cookie `json:"cookie"`
SMTP SMTP `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 (Config) FullAddress ¶
FullAddress returns the scheme, domain, port, and host - including proxy info
func (Config) StaticAddress ¶
StaticAddress adds the static URL to the full address TODO If staticURL is already a valid URL just return that
type Cookie ¶
type Cookie 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"`
}
Cookie 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.
func ParseCookiePath ¶
ParseCookiePath will create a Cookie using the given filepath.
type Database ¶
type Database 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:"sslmode"`
}
Database contains the fields needed to connect to a database.
func ParseDatabasePath ¶
ParseDatabasePath will create a Database using the given filepath.
func ParseDatabaseURL ¶
ParseDatabaseURL will create a Database from the given raw URL
func (Database) Credentials ¶
Credentials with return the driver and credentials appropriate for Go's sql.Open function as strings TODO Return the full address instead of a connection string?
func (Database) FullAddress ¶
FullAddress returns the String output of the db URL
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 SMTP ¶
type SMTP 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"`
}
SMTP contains the fields needed to connect to a SMTP server.
func ParseSMTPPath ¶
ParseSMTPPath will create an SMTP using the given filepath.
func (SMTP) FromAddress ¶
FromAddress creates a string suitable for use in an Email's From header.