web

package
v0.0.0-...-1d50e38 Latest Latest
Warning

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

Go to latest
Published: May 30, 2017 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const JSONMarshalError = "Could not marshal data to JSON"

Variables

View Source
var Chunks = []timePeriod{
	{60 * 60 * 24, "day", "days", "d"},
	{60 * 60, "hour", "hours", "h"},
	{60, "min", "min", "m"},
	{1, "sec", "sec", "s"},
}

Functions

func MakeCommonFunctionMap

func MakeCommonFunctionMap(settings *evergreen.Settings) (template.FuncMap,
	error)

Create function Mappings - Add functions here to make them usable in the template language

Types

type App

type App struct {
	Router         *http.Handler
	TemplateFolder string
	TemplateFuncs  map[string]interface{}
	TemplateCache  map[string]*template.Template
	CacheTemplates bool
	inject.Injector
}

func NewApp

func NewApp() *App

func (*App) MakeHandler

func (ae *App) MakeHandler(handlers ...interface{}) http.HandlerFunc

func (*App) RespondStreamTemplate

func (ae *App) RespondStreamTemplate(templateNames []string, entryPointName string, data interface{}) HTTPResponse

func (*App) RespondTemplate

func (ae *App) RespondTemplate(templateNames []string, entryPointName string, data interface{}) HTTPResponse

type ChainHttpResponse

type ChainHttpResponse struct{}

func (ChainHttpResponse) Render

type HTTPResponse

type HTTPResponse interface {
	Render(w http.ResponseWriter) error
}

HTTPResponse is an interface that is responsible for encapsulating how a response is rendered to an HTTP client.

type HandlerApp

type HandlerApp interface {
	RespondStreamTemplate(templateNames []string, entryPointName string, data interface{}) HTTPResponse
	RespondTemplate(templateNames []string, entryPointName string, data interface{}) HTTPResponse
	MakeHandler(handlers ...interface{}) http.HandlerFunc
}

type JSONResponse

type JSONResponse struct {
	Data       interface{}
	StatusCode int
}

JSONResponse will marshal "Data" as json to the output, and set StatusCode accordingly.

func (JSONResponse) Render

func (jr JSONResponse) Render(w http.ResponseWriter) error

type MutableVar

type MutableVar struct {
	Value interface{}
}

Because Go's templating language for some reason doesn't allow assignments, use this to get around it.

func (*MutableVar) Get

func (self *MutableVar) Get() interface{}

func (*MutableVar) Set

func (self *MutableVar) Set(v interface{}) interface{}

type NullHttpResponse

type NullHttpResponse struct{}

NullHttpResponse doesn't do anything to the response. It can be used if the handler has already written the response directly so no further action needs to be taken.

func (NullHttpResponse) Render

type RawHTTPResponse

type RawHTTPResponse []byte

RawHTTPResponse will write a sequence of bytes directly to the output.

func (RawHTTPResponse) Render

type StringResponse

type StringResponse struct {
	Body       string
	StatusCode int
}

StringResponse will write a simple string directly to the output

func (StringResponse) Render

func (sr StringResponse) Render(w http.ResponseWriter) error

type TemplateResponse

type TemplateResponse struct {
	TemplateName string
	TemplateSet  *template.Template
	Data         interface{}
	Stream       bool
}

TemplateResponse will execute TemplateSet against Data with the root template named by TemplateName.

func (TemplateResponse) Render

type YAMLResponse

type YAMLResponse struct {
	Data       interface{}
	StatusCode int
}

YAMLResponse will marshal "Data" as json to the output, and set StatusCode accordingly.

Jump to

Keyboard shortcuts

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