platform

package
v0.0.0-...-b1c7972 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IPAddress   = "localhost"
	DefaultPort = "8080"
)
View Source
const DBTypeInMemory = "mem"
View Source
const DBTypePostgres = "postgres"
View Source
const PostgresDev = "dev"
View Source
const PostgresProduction = "production"

Variables

View Source
var EmptySignal = models.Signal{}
View Source
var ErrNotFound = errors.New("not found")

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

func GenerateRandomString

func GenerateRandomString(length int) string

func HashPassword

func HashPassword(password string) (string, error)

func SendAPIErrorResp

func SendAPIErrorResp(w io.Writer, message string, status int)

func SendAPIOKResp

func SendAPIOKResp(w io.Writer, message string)

func SendAPIOKRespWithData

func SendAPIOKRespWithData(w io.Writer, message string, data interface{})

func SendAPIResp

func SendAPIResp(w io.Writer, data interface{})

Types

type ErrorViewData

type ErrorViewData struct {
	Title   string      `json:"title"`
	Message string      `json:"message"`
	Error   string      `json:"error"`
	Data    interface{} `json:"data"`
}

type LoginSession

type LoginSession struct {
	Username  string
	SessionID string
}

type LoginSessionManager

type LoginSessionManager struct {
	// contains filtered or unexported fields
}

func NewLoginSessionHandler

func NewLoginSessionHandler() *LoginSessionManager

func (*LoginSessionManager) GetBySessionID

func (manager *LoginSessionManager) GetBySessionID(sessionID string) (*LoginSession, error)

func (*LoginSessionManager) GetByUsername

func (manager *LoginSessionManager) GetByUsername(username string) (*LoginSession, error)

func (*LoginSessionManager) IsUserLoggedIn

func (manager *LoginSessionManager) IsUserLoggedIn(sessionID, username string) bool

func (*LoginSessionManager) IsUserNotLoggedIn

func (manager *LoginSessionManager) IsUserNotLoggedIn(sessionID, username string) bool

func (*LoginSessionManager) New

func (manager *LoginSessionManager) New(username string) string

func (*LoginSessionManager) Remove

func (manager *LoginSessionManager) Remove(username string) error

type ViewsMaker

type ViewsMaker struct {
	// contains filtered or unexported fields
}

func NewViewsMaker

func NewViewsMaker(viewsDir string) (*ViewsMaker, error)

func (*ViewsMaker) RenderErrorView

func (vm *ViewsMaker) RenderErrorView(w http.ResponseWriter, username string, title string, status int, message string)

func (*ViewsMaker) RenderIndex

func (vm *ViewsMaker) RenderIndex(w http.ResponseWriter)

func (*ViewsMaker) RenderView

func (vm *ViewsMaker) RenderView(w http.ResponseWriter, page string, viewData interface{})

type YamlConfig

type YamlConfig struct {
	MuteRequestPathLogs bool   `yaml:"mute_request_path_logs"`
	PingTimeout         int    `yaml:"db_ping_timeout"`
	DBType              string `yaml:"dbtype"`
	// TODO: should have one general env variable
	PostgresEnv string `yaml:"postgres_env"`

	Graphite struct {
		Enabled bool
		Host    string
		Port    int
	}

	DBProd struct {
		Host    string
		Port    int
		Name    string
		User    string
		SSLMode string `yaml:"sslMode"`
	} `yaml:"postgres_production"`
	DBDev struct {
		Host    string
		Port    int
		Name    string
		User    string
		SSLMode string `yaml:"sslMode"`
	} `yaml:"postgres_dev"`
}

func NewYamlConfig

func NewYamlConfig(yamlContent []byte) (*YamlConfig, error)

func (*YamlConfig) GetPostgresDBName

func (c *YamlConfig) GetPostgresDBName() string

func (*YamlConfig) GetPostgresDBSSLMode

func (c *YamlConfig) GetPostgresDBSSLMode() string

func (*YamlConfig) GetPostgresDBUsername

func (c *YamlConfig) GetPostgresDBUsername() string

func (*YamlConfig) GetPostgresHost

func (c *YamlConfig) GetPostgresHost() string

func (*YamlConfig) GetPostgresPort

func (c *YamlConfig) GetPostgresPort() int

Jump to

Keyboard shortcuts

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