webui

package
v1.5.5 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ListenAddr, URL, TOTP, FilesPath string
	LeaderboardLimit                 int
	Log                              *log.Log
	Debug                            bool
	DB                               *database.DB
}

Config contains all the necessary config options to start and serve a web UI.

type Handlers

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

Handlers contains all the http.HandlerFuncs that serve the web UI's routes.

func (*Handlers) Home

func (h *Handlers) Home(w http.ResponseWriter, r *http.Request)

Home redirects to the leaderboard view.

func (*Handlers) Leaderboard

func (h *Handlers) Leaderboard(w http.ResponseWriter, r *http.Request)

Leaderboard serves the leaderboard view.

func (*Handlers) MustAuth

func (h *Handlers) MustAuth(next http.HandlerFunc) http.HandlerFunc

MustAuth wraps an http.HandlerFunc and ensures that the user is authenticated before the said HandlerFunc is executed. The user is redirected to a "session expired" page if they are not authenticated.

func (*Handlers) NotFound

func (h *Handlers) NotFound(w http.ResponseWriter, r *http.Request)

NotFound handles invalid URIs that do not have a matching route.

type Provider

type Provider struct {
	Config *Config
	// contains filtered or unexported fields
}

A Provider provides a UI service that can be attached to karmabot.

func New

func New(config *Config) (*Provider, error)

New returns a new instance the web UI provider. It also generates a TOTP token and quits if one is not passed.

func (*Provider) GetURL

func (p *Provider) GetURL(URI string) (string, error)

GetURL returns the passed URI as a full URL with an authentication token that is valid for 30 seconds.

func (*Provider) Listen

func (p *Provider) Listen() error

Listen starts the HTTP server.

type UI

type UI struct {
	Config *Config
	// contains filtered or unexported fields
}

A UI is the part of the web UI that handles everything HTTP i.e. the actual web UI.

func (*UI) Init

func (u *UI) Init()

Init initializes the web UI by parsing the HTML templates and setting up the HTTP routes.

func (*UI) Listen

func (u *UI) Listen()

Listen starts the actual HTTP server.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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