views

package
v0.0.0-...-b1582e7 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoTemplate is returned when a requested template is not found
	ErrNoTemplate = errors.New("no such template")
)

Functions

func CheckDatabase

func CheckDatabase(db *bolt.DB) error

CheckDatabase performs sanity checks on the database provided

func ToHandler

func ToHandler(v ViewHandler, ts *Templates) http.Handler

Types

type ConfirmHandler

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

func NewConfirmHandler

func NewConfirmHandler(ts *Templates, db *bolt.DB, prefix string) *ConfirmHandler

func (*ConfirmHandler) ServeHTTP

func (ch *ConfirmHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) error

type ServerHandler

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

func NewServerHandler

func NewServerHandler(fs fs.Dir, ts *Templates, db *bolt.DB) *ServerHandler

func (*ServerHandler) ServeHTTP

func (sh *ServerHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) error

type StaticPageHandler

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

StaticPageHandler serves a single static html page

func NewStaticPageHandler

func NewStaticPageHandler(ts *Templates, page string) *StaticPageHandler

func (*StaticPageHandler) ServeHTTP

func (sh *StaticPageHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) error

type Templates

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

Templates handles operations on templates.

func NewTemplates

func NewTemplates(path, glob string) (*Templates, error)

NewTemplates creates a new instance of Templates from the provided folder and glob

func (*Templates) Error

func (t *Templates) Error(rw http.ResponseWriter, status int, message string)

Error renders the error.html template with the given parameters

func (*Templates) Render

func (t *Templates) Render(rw http.ResponseWriter, templateName string, data interface{})

Render renders the named template passing the provided data as context. If the template does not exist, Render panics

type UploadHandler

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

func NewUploadHandler

func NewUploadHandler(fs fs.Dir, ts *Templates, db *bolt.DB, m *mailer.M, prefix string) *UploadHandler

func (*UploadHandler) ServeHTTP

func (uh *UploadHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) error

type ViewError

type ViewError struct {
	Err    error
	Status int
}

ViewError contains both the original error and the status code to be returned to the client

func ViewErr

func ViewErr(err error, status int) *ViewError

func (*ViewError) Error

func (v *ViewError) Error() string

type ViewHandler

type ViewHandler interface {
	ServeHTTP(http.ResponseWriter, *http.Request) error
}

Jump to

Keyboard shortcuts

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