handlers

package
v0.0.0-...-b9c0981 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrRenderingPage is the text displayed if we get an error during rendering
	ErrRenderingPage = "Error rendering page"
)

Variables

This section is empty.

Functions

func ErrorHandler

func ErrorHandler(w http.ResponseWriter, _ *http.Request, err error)

ErrorHandler renders a response when an error occurs

func RegisterTemplate

func RegisterTemplate(name TemplateName, fmap template.FuncMap, templates ...string) error

RegisterTemplate creates a html template with a name, and a FuncMap for a set of template strings, along with a list of 'templates' which will include the 'layout', 'header', 'footer' and 'content' etc

Types

type DashboardParams

type DashboardParams struct {
	// FS provides access to static files
	FS *hashfs.FS

	session.SessionStore
}

DashboardParams configure the Dashboard http handler

func (DashboardParams) Dashboard

func (p DashboardParams) Dashboard(w http.ResponseWriter, r *http.Request)

Dashboard page is accessible to logged in users only, the proptection for that is provide by KratoAuthMiddleware middleware

func (DashboardParams) ResponderFunc

func (p DashboardParams) ResponderFunc() func(w http.ResponseWriter, r *http.Request)

type HomeParams

type HomeParams struct {
	session.SessionStore
	FS *hashfs.FS
}

HomeParams configure the Home http handler

func (HomeParams) Home

func (p HomeParams) Home(w http.ResponseWriter, r *http.Request)

Home displays a simple homepage

type LoginParams

type LoginParams struct {
	// FS provides access to static files
	FS *hashfs.FS

	// FlowRedirectURL is the kratos URL to redirect the browser to,
	// when the user wishes to login, and the 'flow' query param is missing
	FlowRedirectURL string
}

LoginParams configure the Login http handler

func (LoginParams) Login

func (lp LoginParams) Login(w http.ResponseWriter, r *http.Request)

Login handler displays the login screen

type LogoutParams

type LogoutParams struct {
	// FS provides access to static files
	FS *hashfs.FS

	// FlowRedirectURL is the kratos URL to redirect the browser to,
	// when the user wishes to logout, and the 'flow' query param is missing
	FlowRedirectURL string
}

LogoutParams configure the Logout http handler

func (LogoutParams) Logout

func (lp LogoutParams) Logout(w http.ResponseWriter, r *http.Request)

Logout handler clears the session & logs the user out

type RecoveryParams

type RecoveryParams struct {
	// FS provides access to static files
	FS *hashfs.FS

	// FlowRedirectURL is the kratos URL to redirect the browser to,
	// when the user wishes to start recovery, and the 'flow' query param is missing
	FlowRedirectURL string
}

RecoveryParams configure the Recovery http handler

func (RecoveryParams) Recovery

func (rp RecoveryParams) Recovery(w http.ResponseWriter, r *http.Request)

Recovery handler displays the recovery screen, which allows the user to enter and email address, the email contains a link to authenticate the user

type RegistrationParams

type RegistrationParams struct {
	// FS provides access to static files
	FS *hashfs.FS

	// FlowRedirectURL is the kratos URL to redirect the browser to,
	// when the user wishes to register, and the 'flow' query param is missing
	FlowRedirectURL string
}

RegistrationParams configure the Registration http handler

func (RegistrationParams) Registration

func (rp RegistrationParams) Registration(w http.ResponseWriter, r *http.Request)

Registration directs the user to a page where they can sign-up or register to use the site

type SettingsParams

type SettingsParams struct {
	// FS provides access to static files
	FS *hashfs.FS

	// FlowRedirectURL is the kratos URL to redirect the browser to,
	// when the user wishes to edit their settings, and the 'flow' query param is missing
	FlowRedirectURL string
}

SettingsParams configure the Settings http handler

func (SettingsParams) Settings

func (lp SettingsParams) Settings(w http.ResponseWriter, r *http.Request)

Settings handler displays the Settings screen that allows the user to change their details

type Template

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

Template wraps an html/template

func GetTemplate

func GetTemplate(name TemplateName) Template

GetTemplate returns template with name or nil

func (Template) Render

func (t Template) Render(name string, w http.ResponseWriter, r *http.Request, dataMap map[string]interface{}) error

Render executes the template 'name' passing dataMap

type TemplateName

type TemplateName string

TemplateName provides a typesafe way of referring to templates

Jump to

Keyboard shortcuts

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