web

package
v0.0.0-...-783bbf4 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2015 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package web provides an HTTP server for the dashboard application

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Getenv

func Getenv(envVarName string, defaultValue string) string

Getenv returns the value of the env var with the given name, or fallback to the given default value.

func RunHttpServer

func RunHttpServer()

RunHttpServer runs an HTTP server on a port defined by the PORT env var (default to 8080)

Types

type Context

type Context struct {
	ClientWrapper *api.ClientWrapper
	Render        *render.Render
	Stats         *stats.Stats
}

Context is a web context used to answer to requests.

func NewContext

func NewContext() *Context

NewContext builds a new Context instance

func (*Context) HomeHandler

func (c *Context) HomeHandler(w http.ResponseWriter, req *http.Request, _ httprouter.Params)

HomeHandler answers HTTP requests by loading data for all resource types and using the "home" view

func (*Context) StatsHandler

func (c *Context) StatsHandler(w http.ResponseWriter, req *http.Request, _ httprouter.Params)

StatsHandler answers HTTP requests with the stats in JSON format

type Data

type Data struct {
	*api.Data
}

Data represents the data retrieved from the API, and exposed to view

func (*Data) Title

func (d *Data) Title() string

Title returns the title of the page using either the env var DASHBOARD_TITLE or a default title.

Jump to

Keyboard shortcuts

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