Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeHTTPRouter ¶
func MakeHTTPRouter(db lurkcoin.Database, config *Config) *httprouter.Router
func StartServer ¶
func StartServer(config *Config)
Types ¶
type AdminLoginDetails ¶
type AdminLoginDetails map[string]struct { PasswordHash string `yaml:"password_hash"` HashAlgorithm string `yaml:"hash_algorithm"` PasswordSalt string `yaml:"password_salt"` AllowEditing bool `yaml:"allow_editing"` AllowDatabaseDownload bool `yaml:"allow_database_download"` }
func (AdminLoginDetails) Validate ¶
func (self AdminLoginDetails) Validate(username, password string) bool
TODO: Provide a more secure hashing function.
type Config ¶
type Config struct { // The name of this service (for example "lurkcoin"). This is also used as // the default server name for the v2 API. Name string `yaml:"name"` // The network protocol to use when binding to the socket. Defaults to // "tcp", can be set to "unix" for example. NetworkProtocol string `yaml:"network_protocol"` // The address to bind to (optional) and port. Address string `yaml:"address"` Port uint16 `yaml:"port"` // An optional logfile Logfile string `yaml:"logfile"` Database struct { Type string `yaml:"type"` Location string `yaml:"location"` Options map[string]string `yaml:"options"` } `yaml:"database"` // TLS TLS struct { Enable bool `yaml:"enable"` CertFile string `yaml:"cert_file"` KeyFile string `yaml:"key_file"` } `yaml:"tls"` // Admin pages AdminPages struct { Enable bool `yaml:"enable"` Users AdminLoginDetails `yaml:"users"` } `yaml:"admin_pages"` // HTTP redirects Redirects map[string]string `yaml:"redirects"` // The minimum HTTPS API version to support. MinAPIVersion uint8 `yaml:"min_api_version"` // Suppresses any HTTP-related logs such as TLS handshake errors. SuppressHTTPLogs bool `yaml:"suppress_http_logs"` // Disables HTTP keep-alives. DisableHTTPKeepAlives bool `yaml:"disable_http_keepalives"` }
func LoadConfig ¶
type HTTPHandler ¶
type HTTPHandler func(*HTTPRequest) (interface{}, error)
type HTTPRequest ¶
type HTTPRequest struct { Server *lurkcoin.Server Database lurkcoin.Database DbTransaction *lurkcoin.DatabaseTransaction Request *http.Request Params httprouter.Params }
A HTTP server wrapper
func MakeHTTPRequest ¶
func MakeHTTPRequest(db lurkcoin.Database, request *http.Request, params httprouter.Params) *HTTPRequest
func (*HTTPRequest) AbortTransaction ¶
func (self *HTTPRequest) AbortTransaction()
func (*HTTPRequest) Authenticate ¶
func (self *HTTPRequest) Authenticate(otherServers ...string) error
func (*HTTPRequest) AuthenticateV2 ¶
func (self *HTTPRequest) AuthenticateV2(query v2Form, otherServers ...string) error
func (*HTTPRequest) FinishTransaction ¶
func (self *HTTPRequest) FinishTransaction()
func (*HTTPRequest) Unmarshal ¶
func (self *HTTPRequest) Unmarshal(v interface{}) error
Unmarshals JSON sent in the HTTP request into v.
Click to show internal directories.
Click to hide internal directories.