controllers

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PopulateTemplates

func PopulateTemplates(templateFiles embed.FS) *template.Template

PopulateTemplates loads and parses all of the templates in the templates directory

func Register

func Register(db *sql.DB, authorizer httpauth.Authorizer, authBackend httpauth.AuthBackend,
	roles map[string]httpauth.Role, templates *template.Template, pinger *pinger.Pinger,
	version string, cookieKey []byte, secureCookie bool, publicFiles embed.FS)

Register the handlers for a given route.

Types

type CurrentUserGetter

type CurrentUserGetter interface {
	CurrentUser(rw http.ResponseWriter, req *http.Request) (user httpauth.UserData, e error)
	Messages(rw http.ResponseWriter, req *http.Request) []string
}

CurrentUserGetter gets the current user from the http request

type MockCurrentUserGetter

type MockCurrentUserGetter struct {
	FlashMessages []string
	Username      string
	UserError     error
}

MockCurrentUserGetter provides the base struct for the methods to mock the httpauth package. The properties on this struct can vary the results returned.

func (MockCurrentUserGetter) CurrentUser

func (m MockCurrentUserGetter) CurrentUser(rw http.ResponseWriter,
	req *http.Request) (user httpauth.UserData, e error)

CurrentUser is the mock of the CurrentUser method from the httpauth package.

func (MockCurrentUserGetter) Messages

Messages is the mock of the Messasges method from the httpauth package.

Jump to

Keyboard shortcuts

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