Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Templates = tmplutil.Templater{ FileSystem: embedFS, Includes: map[string]string{ "error": "components/error.html", "title": "components/title.html", "header": "components/header.html", }, Functions: template.FuncMap{ "sprint": fmt.Sprint, "sprintf": fmt.Sprintf, "sprintln": fmt.Sprintln, "initials": func(str string) string { r := []rune(str) if len(r) == 0 { return "" } return string(unicode.ToUpper(r[0])) }, "map": func(v ...interface{}) map[string]interface{} { m := make(map[string]interface{}, len(v)/2) for i := 0; i < len(v); i++ { switch k := v[i].(type) { case string: i++ m[k] = v[i] case map[string]interface{}: for k, v := range k { m[k] = v } default: log.Panicf("invalid map key type %T", k) } } return m }, "datetime": func(t time.Time) string { return t.UTC().Format("2006-01-02T15:04:05Z") }, "datestamp": func(t time.Time) string { return t.Format(time.Stamp) }, }, OnRenderFail: func(sub *tmplutil.Subtemplate, w io.Writer, err error) { self := sub.Templater() self.Subtemplate("error").Execute(w, err) }, }
Templates is a collection of templates.
Functions ¶
func HashPassword ¶
HashPassword hashes the password into an opaque format.
func OverrideFS ¶
OverrideFS overrides the template filesystem with the given filesystem.
func StaticHandler ¶
StaticHandler is an http.Handler that serves the static files.
Types ¶
type PasswordSafe ¶
type PasswordSafe struct {
// contains filtered or unexported fields
}
PasswordSafe stores users and their passwords. A zero value is safe to use.
func (*PasswordSafe) Add ¶
func (s *PasswordSafe) Add(users []BasicUser)
Add adds users. It is NOT safe to use concurrently.
func (*PasswordSafe) Authenticate ¶
func (s *PasswordSafe) Authenticate(username, password string) bool
Authenticate checks if the given username and password is valid. It is safe to use concurrently as long as Add is not called.
For reference, refer to Caddy's modules/caddyhttp/caddyauth/basicauth.go.
Click to show internal directories.
Click to hide internal directories.