Documentation ¶
Index ¶
- Constants
- Variables
- func MakeCommonFunctionMap(settings *evergreen.Settings) (template.FuncMap, error)
- type App
- type ChainHttpResponse
- type HTTPResponse
- type HandlerApp
- type JSONResponse
- type MutableVar
- type NullHttpResponse
- type RawHTTPResponse
- type StringResponse
- type TemplateResponse
- type YAMLResponse
Constants ¶
const JSONMarshalError = "Could not marshal data to JSON"
Variables ¶
var Chunks = []timePeriod{
{60 * 60 * 24, "day", "days", "d"},
{60 * 60, "hour", "hours", "h"},
{60, "min", "min", "m"},
{1, "sec", "sec", "s"},
}
Functions ¶
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 (*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 ¶
func (nh ChainHttpResponse) Render(w http.ResponseWriter) error
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 ¶
func (nh NullHttpResponse) Render(w http.ResponseWriter) error
type RawHTTPResponse ¶
type RawHTTPResponse []byte
RawHTTPResponse will write a sequence of bytes directly to the output.
func (RawHTTPResponse) Render ¶
func (rw RawHTTPResponse) Render(w http.ResponseWriter) error
type StringResponse ¶
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 ¶
func (tr TemplateResponse) Render(w http.ResponseWriter) error
type YAMLResponse ¶
type YAMLResponse struct { Data interface{} StatusCode int }
YAMLResponse will marshal "Data" as json to the output, and set StatusCode accordingly.