wsframe

package module
v0.0.0-...-d2cf7a6 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2020 License: GPL-3.0 Imports: 19 Imported by: 0

README

wsframe

A basic, golang, SPA, web, framework.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TemplateFuncs = template.FuncMap{
	"unescaped": func(x string) interface{} {
		return template.HTML(x)
	},
	"sha1sum": func(x string) string {
		return fmt.Sprintf("%x", sha1.Sum([]byte(x)))
	},
	"subtract": func(a, b int) int {
		return a - b
	},
	"add": func(a, b int) int {
		return a + b
	},
	"multiply": func(a, b int) int {
		return a * b
	},
	"divide": func(a, b int) int {
		return a / b
	},
	"usd": func(x int) string {
		return fmt.Sprintf("$%.2f", float64(x)/float64(100))
	},
	"css": func(s string) template.CSS {
		return template.CSS(s)
	},
	"tokey":   ToKey,
	"fromkey": FromKey,
}

Functions

func FromKey

func FromKey(s string) string

func ToKey

func ToKey(s string) string

Types

type App

type App struct {
	Name         string `json:"name"`
	HashKey      string `json:"hashkey"`
	BlockKey     string `json:"blockkey"`
	SecureCookie *securecookie.SecureCookie
	Templates    *template.Template
	Port         string `json:"port"`
	SSLPort      string `json:"sslport"`
	Database     struct {
		User     string `json:"user"`
		Password string `json:"password"`
		Name     string `json:"name"`
	} `json:"database"`
	Driver *sql.DB
	Routes []struct {
		Route string `json:"route"`
		Admin struct {
			Table       string `json:"table"`
			Key         string `json:"key"`
			Template    string `json:"template"`
			Controllers string `json:"controllers"`
		} `json:"admin"`
		Authorized struct {
			Privilege   string `json:"privilege"`
			Table       string `json:"table"`
			Key         string `json:"key"`
			Template    string `json:"template"`
			Controllers string `json:"controllers"`
		} `json:"authorized"`
		Table       string `json:"table"`
		Key         string `json:"key"`
		Template    string `json:"template"`
		Controllers string `json:"controllers"`
	} `json:"routes"`
	Added []struct {
		Route   string
		Handler func(c *wsrooms.Conn, msg *wsrooms.Message, matches []string)
	}
	Router *mux.Router
}

func NewApp

func NewApp(cj string) *App

func (*App) AddRoute

func (wfa *App) AddRoute(path string, handler func(c *wsrooms.Conn, msg *wsrooms.Message, matches []string))

func (*App) GetRow

func (wfa *App) GetRow(table, key string) map[string]interface{}

func (*App) GetRows

func (wfa *App) GetRows(table string) []map[string]interface{}

func (*App) InsertRow

func (wfa *App) InsertRow(table, key, value string) error

func (*App) ReadCookie

func (wfa *App) ReadCookie(r *http.Request) map[string]string

func (*App) Render

func (wfa *App) Render(c *wsrooms.Conn, msg *wsrooms.Message, template string, controllers []string, data interface{})

func (*App) SetCookie

func (wfa *App) SetCookie(w http.ResponseWriter, r *http.Request, value map[string]string, logout bool)

func (*App) Start

func (wfa *App) Start()

type Auth

type Auth struct {
	Alias     string `json:"alias,omitempty"`
	Passhash  string `json:"passhash"`
	Salt      string `json:"salt"`
	Hash      string `json:"hash"`
	Privilege string `json:"privilege"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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