Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyJPath(data interface{}, jpath string) (interface{}, error)
- func DefaultFavicon() []byte
- func Dir(useLocal bool, name string) http.FileSystem
- func EvalInline(input string, data map[string]interface{}, funcs FuncMap, names ...string) (string, error)
- func FS(useLocal bool) http.FileSystem
- func FSByte(useLocal bool, name string) ([]byte, error)
- func FSMustByte(useLocal bool, name string) []byte
- func FSMustString(useLocal bool, name string) string
- func FSString(useLocal bool, name string) (string, error)
- func IsDirectoryErr(err error) bool
- func IsDirectoryError(err error) bool
- func IsHardStop(err error) bool
- func MinNonZero(data stats.Float64Data) (float64, error)
- func MultiReadCloser(readers ...io.Reader) *multiReadCloser
- func MustEvalInline(input string, data map[string]interface{}, funcs FuncMap, names ...string) string
- func PrettifyHTML(in string) (string, error)
- func RegisterActionStep(typeName string, performable Performable)
- func RegisterPostprocessor(name string, ppfunc PostprocessorFunc)
- func RegisterProtocol(scheme string, protocol Protocol)
- func RegisterRenderer(name string, renderer Renderer)
- func TrimEmptyLines(in string) (string, error)
- type Action
- type AddHandlerFunc
- type Authenticator
- type AuthenticatorConfig
- type AuthenticatorConfigs
- type BasicAuthenticator
- func (self *BasicAuthenticator) AddPasswdFile(filename string) error
- func (self *BasicAuthenticator) Authenticate(w http.ResponseWriter, req *http.Request) bool
- func (self *BasicAuthenticator) Callback(w http.ResponseWriter, req *http.Request)
- func (self *BasicAuthenticator) IsCallback(_ *url.URL) bool
- func (self *BasicAuthenticator) Name() string
- type Binding
- type BindingErrorAction
- type Engine
- type FileMount
- func (self *FileMount) GetMountPoint() string
- func (self *FileMount) Open(name string) (http.File, error)
- func (self *FileMount) OpenWithType(name string, req *http.Request, requestBody io.Reader) (*MountResponse, error)
- func (self *FileMount) String() string
- func (self *FileMount) WillRespondTo(name string, req *http.Request, requestBody io.Reader) bool
- type Fragment
- type FragmentSet
- func (self FragmentSet) DebugOutput() []byte
- func (self FragmentSet) Get(name string) (*Fragment, bool)
- func (self FragmentSet) HasLayout() bool
- func (self FragmentSet) Header(server *Server) TemplateHeader
- func (self *FragmentSet) Parse(name string, source io.Reader) error
- func (self *FragmentSet) Set(name string, header *TemplateHeader, data []byte) error
- type FuncMap
- type HttpProtocol
- type MarkdownRenderer
- type Mount
- type MountConfig
- type MountResponse
- func (self *MountResponse) Close() error
- func (self *MountResponse) GetFile() http.File
- func (self *MountResponse) GetPayload() interface{}
- func (self *MountResponse) IsDir() bool
- func (self *MountResponse) ModTime() time.Time
- func (self *MountResponse) Mode() os.FileMode
- func (self *MountResponse) Name() string
- func (self *MountResponse) Read(p []byte) (int, error)
- func (self *MountResponse) Readdir(count int) ([]os.FileInfo, error)
- func (self *MountResponse) Seek(offset int64, whence int) (int64, error)
- func (self *MountResponse) Size() int64
- func (self *MountResponse) Stat() (os.FileInfo, error)
- func (self *MountResponse) Sys() interface{}
- type OauthAuthenticator
- type PaginatorConfig
- type PdfRenderer
- type Performable
- type PostprocessorFunc
- type PrewriteFunc
- type ProcessStep
- type Protocol
- type ProtocolConfig
- type ProtocolRequest
- type ProtocolResponse
- type ProxyMount
- func (self *ProxyMount) GetMountPoint() string
- func (self *ProxyMount) Open(name string) (http.File, error)
- func (self *ProxyMount) OpenWithType(name string, req *http.Request, requestBody io.Reader) (*MountResponse, error)
- func (self *ProxyMount) String() string
- func (self *ProxyMount) WillRespondTo(name string, req *http.Request, requestBody io.Reader) bool
- type Redirect
- type RedirectTo
- type RedisProtocol
- type RenderOptions
- type Renderer
- type RespondStep
- type ResultsPage
- type SassRenderer
- type Server
- func (self *Server) Connect(route string, handler http.HandlerFunc)
- func (self *Server) Delete(route string, handler http.HandlerFunc)
- func (self *Server) Get(route string, handler http.HandlerFunc)
- func (self *Server) GetTemplateData(req *http.Request, header *TemplateHeader) (FuncMap, map[string]interface{}, error)
- func (self *Server) GetTemplateFunctions(data map[string]interface{}, header *TemplateHeader) FuncMap
- func (self *Server) Handle(route string, handler http.Handler)
- func (self *Server) HandleFunc(route string, handler http.HandlerFunc)
- func (self *Server) Head(route string, handler http.HandlerFunc)
- func (self *Server) Initialize() error
- func (self *Server) IsInRootPath(path string) bool
- func (self *Server) ListenAndServe(address string) error
- func (self *Server) LoadConfig(filename string) error
- func (self *Server) LoadLayout(name string) (io.Reader, error)
- func (self *Server) Options(route string, handler http.HandlerFunc)
- func (self *Server) P(req *http.Request, param string, fallback ...interface{}) typeutil.Variant
- func (self *Server) Patch(route string, handler http.HandlerFunc)
- func (self *Server) Post(route string, handler http.HandlerFunc)
- func (self *Server) Put(route string, handler http.HandlerFunc)
- func (self *Server) RunStartCommand(scmds []*StartCommand, waitForCommand bool) (bool, error)
- func (self *Server) Serve() error
- func (self *Server) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (self *Server) SetFileSystem(fs http.FileSystem)
- func (self *Server) SetMounts(mounts []Mount)
- func (self *Server) ShouldReturnSource(req *http.Request) bool
- func (self *Server) ToTemplateName(requestPath string) string
- func (self *Server) Trace(route string, handler http.HandlerFunc)
- type ShellAuthenticator
- type ShellStep
- type StartCommand
- type StaticAuthenticator
- type StepConfig
- type SwitchCase
- type Template
- func (self *Template) AddPostProcessors(postprocessors ...string) error
- func (self *Template) Engine() Engine
- func (self *Template) Funcs(funcs FuncMap)
- func (self *Template) ParseFragments(fragments FragmentSet) error
- func (self *Template) ParseFrom(r io.Reader) error
- func (self *Template) ParseString(input string) error
- func (self *Template) Render(w io.Writer, data interface{}, subtemplate string) error
- func (self *Template) SetDelimiters(open string, close string)
- func (self *Template) SetEngine(engine Engine)
- func (self *Template) SetHeaderOffset(offset int)
- func (self *Template) SetPrewriteFunc(fn func())
- type TemplateHeader
- type TemplateRenderer
- type TlsConfig
Constants ¶
const ( ActionSummarize BindingErrorAction = `summarize` ActionPrint = `print` ActionContinue = `continue` ActionBreak = `break` ActionIgnore = `ignore` )
const ApplicationName = `diecast`
const ApplicationSummary = `a standalone site templating engine that consumes REST services and renders static HTML output in realtime`
const ApplicationVersion = `1.13.15`
const ContentTemplateName = `content`
const ContextRequestKey = `diecast-request-id`
const DebuggingQuerystringParam = `__viewsource`
const DefaultAddress = `127.0.0.1:28419`
const DefaultColorPalette = `munin`
const DefaultConfigFile = `diecast.yml`
const DefaultErrorsPath = `/_errors`
const DefaultHeaderJoiner = `,`
const DefaultLayoutsPath = `/_layouts`
const DefaultQueryJoiner = `,`
const DefaultRoutePrefix = `/`
const LayoutTemplateName = `layout`
Variables ¶
var AllowInsecureLoopbackBindings bool
var Base32Alphabet = base32.NewEncoding(`abcdefghijklmnopqrstuvwxyz234567`)
var BindingClient = &http.Client{ Timeout: 60 * time.Second, }
var ConvertRoundToPlaces = 12
var DefaultActionStepTimeout = 10 * time.Second
var DefaultAutoindexFilename = `/autoindex.html`
var DefaultAutolayoutPatterns = []string{
`*.html`,
`*.md`,
}
var DefaultBindingTimeout = 10 * time.Second
var DefaultFilterEnvVars = []string{
`_*`,
`*KEY*`,
`*PASSWORD*`,
`*PID*`,
`*HOST*`,
`*URL*`,
`*SECRET*`,
`*TOKEN*`,
`AWS_ACCESS_KEY_ID`,
`AWS_SECRET_ACCESS_KEY`,
`PROMPT_COMMAND`,
`PWD`,
}
var DefaultIndexFile = `index.html`
var DefaultLocale = language.AmericanEnglish
var DefaultOauth2SessionCookieName = `DCO2SESSION`
var DefaultParamJoiner = `;`
var DefaultProxyMountTimeout = time.Duration(10) * time.Second
var DefaultRendererMappings = map[string]string{
`md`: `markdown`,
`scss`: `sass`,
}
var DefaultShellSessionCookieName = `DCSESSION`
var DefaultTemplatePatterns = []string{`*.html`, `*.md`, `*.scss`}
var DefaultTryExtensions = []string{`html`, `md`}
var DefaultVerifyFile = `/` + DefaultIndexFile
var DirectoryErr = errors.New(`is a directory`)
var HeaderSeparator = []byte{'-', '-', '-'}
var ITotallyUnderstandRunningArbitraryCommandsAsRootIsRealRealBad = false
var MaxBufferedBodySize = 16535
var MountHaltErr = errors.New(`mount halted`)
var SassIndentString = ` `
Functions ¶
func ApplyJPath ¶ added in v1.12.12
func DefaultFavicon ¶ added in v1.12.11
func DefaultFavicon() []byte
func Dir ¶
func Dir(useLocal bool, name string) http.FileSystem
Dir returns a http.Filesystem for the embedded assets on a given prefix dir. If useLocal is true, the filesystem's contents are instead used.
func EvalInline ¶
func FS ¶
func FS(useLocal bool) http.FileSystem
FS returns a http.Filesystem for the embedded assets. If useLocal is true, the filesystem's contents are instead used.
func FSByte ¶
FSByte returns the named file from the embedded assets. If useLocal is true, the filesystem's contents are instead used.
func FSMustByte ¶
FSMustByte is the same as FSByte, but panics if name is not present.
func FSMustString ¶
FSMustString is the string version of FSMustByte.
func IsDirectoryErr ¶ added in v1.11.2
func IsDirectoryError ¶
func IsHardStop ¶
func MinNonZero ¶
func MinNonZero(data stats.Float64Data) (float64, error)
func MultiReadCloser ¶ added in v1.10.7
func MustEvalInline ¶ added in v1.12.8
func PrettifyHTML ¶
func RegisterActionStep ¶ added in v1.11.0
func RegisterActionStep(typeName string, performable Performable)
Register a performable step type to the given type name.
func RegisterPostprocessor ¶
func RegisterPostprocessor(name string, ppfunc PostprocessorFunc)
func RegisterProtocol ¶ added in v1.12.1
Register a new protocol handler that will handle URLs with the given scheme.
func RegisterRenderer ¶ added in v1.13.11
func TrimEmptyLines ¶
Types ¶
type Action ¶ added in v1.11.0
type Action struct { Name string `json:"name,omitempty"` Path string `json:"path"` Method interface{} `json:"method"` Steps []*StepConfig `json:"steps"` }
func (*Action) ServeHTTP ¶ added in v1.11.0
func (self *Action) ServeHTTP(w http.ResponseWriter, req *http.Request)
Performs the action in response to an HTTP request, evaluating all action steps. Steps are responsible for generating and manipulating output. The output of the last step will be returned, or an error will be returned if not nil.
type AddHandlerFunc ¶ added in v1.12.1
type AddHandlerFunc func(verb string, route string, handler http.HandlerFunc) (string, string, http.HandlerFunc)
type Authenticator ¶
type AuthenticatorConfig ¶
type AuthenticatorConfigs ¶
type AuthenticatorConfigs []AuthenticatorConfig
func (AuthenticatorConfigs) Authenticator ¶
func (self AuthenticatorConfigs) Authenticator(req *http.Request) (Authenticator, error)
type BasicAuthenticator ¶
type BasicAuthenticator struct {
// contains filtered or unexported fields
}
func NewBasicAuthenticator ¶
func NewBasicAuthenticator(config *AuthenticatorConfig) (*BasicAuthenticator, error)
func (*BasicAuthenticator) AddPasswdFile ¶
func (self *BasicAuthenticator) AddPasswdFile(filename string) error
func (*BasicAuthenticator) Authenticate ¶
func (self *BasicAuthenticator) Authenticate(w http.ResponseWriter, req *http.Request) bool
func (*BasicAuthenticator) Callback ¶ added in v1.10.10
func (self *BasicAuthenticator) Callback(w http.ResponseWriter, req *http.Request)
func (*BasicAuthenticator) IsCallback ¶ added in v1.10.10
func (self *BasicAuthenticator) IsCallback(_ *url.URL) bool
func (*BasicAuthenticator) Name ¶ added in v1.11.0
func (self *BasicAuthenticator) Name() string
type Binding ¶
type Binding struct { // The name of the key in the $.bindings template variable. Name string `json:"name,omitempty"` // Only evaluate the template on request URL paths matching one of the regular expressions in this array. Restrict []string `json:"restrict,omitempty"` // Only evaluate the binding if this expression yields a truthy value. OnlyIfExpr string `json:"only_if,omitempty"` // Do not evaluate the binding if this expression yields a truthy value. NotIfExpr string `json:"not_if,omitempty"` // The protocol-specific method to perform the request with. Method string `json:"method,omitempty"` // The URL that specifies the protocol and resource to retrieve. Resource string `json:"resource,omitempty"` // A duration specifying the timeout for the request. Timeout interface{} `json:"timeout,omitempty"` // If the protocol supports an insecure request mode (e.g.: HTTPS), permit it in this case. Insecure bool `json:"insecure,omitempty"` // A set of additional parameters to include in the request (e.g.: HTTP query string parameters) Params map[string]interface{} `json:"params,omitempty"` // If a parameter is provided as an array, but must be a string in the request, how shall the array elements be joined. ParamJoiner string `json:"param_joiner,omitempty"` // Additional headers to include in the request. Headers map[string]string `json:"headers,omitempty"` // If the request receives an open-ended body, this will allow structured data to be passed in. BodyParams map[string]interface{} `json:"body,omitempty"` // If the request receives an open-ended body, this will allow raw data to be passed in as-is. RawBody string `json:"rawbody,omitempty"` // How to serialize BodyParams into a string before the request is made. Formatter string `json:"formatter,omitempty"` // How to parse the response content from the request. Parser string `json:"parser,omitempty"` // Disable templating of variables in this binding. NoTemplate bool `json:"no_template,omitempty"` // Whether the request failing will cause a page-wide error or be ignored. Optional bool `json:"optional,omitempty"` // The value to place in $.bindings if the request fails. Fallback interface{} `json:"fallback,omitempty"` // Actions to take if the request fails. OnError BindingErrorAction `json:"on_error,omitempty"` // Actions to take in response to specific numeric response status codes. IfStatus map[string]BindingErrorAction `json:"if_status,omitempty"` // A templated value that yields an array. The binding request will be performed once for each array element, wherein // the Resource value is passed into a template that includes the $index and $item variables, which represent the repeat // array item's position and value, respectively. Repeat string `json:"repeat,omitempty"` // Do not passthrough the headers that were sent to the template from the client's browser, even if Passthrough mode is enabled. SkipInheritHeaders bool `json:"skip_inherit_headers,omitempty"` // Reserved for future use. DisableCache bool `json:"disable_cache,omitempty"` // An open-ended set of options that are available for protocol implementations to use. ProtocolOptions map[string]interface{} `json:"protocol,omitempty"` // A specialized repeater configuration that automatically performs pagination on an upstream request, aggregating // the results before returning them. Paginate *PaginatorConfig `json:"paginate,omitempty"` // Specifies a JSONPath expression that can be used to transform the response data received from the binding // into the data that is provided to the template. Transform string `json:"transform,omitempty"` // contains filtered or unexported fields }
type BindingErrorAction ¶
type BindingErrorAction string
type FileMount ¶
type FileMount struct { MountPoint string `json:"mount"` Path string `json:"source"` Passthrough bool `json:"passthrough"` FileSystem http.FileSystem `json:"-"` }
A FileMount exposes the contents of a given filesystem directory.
func (*FileMount) GetMountPoint ¶
func (*FileMount) OpenWithType ¶
type Fragment ¶ added in v1.11.0
type Fragment struct { Name string Header *TemplateHeader Data []byte }
type FragmentSet ¶ added in v1.11.0
type FragmentSet []*Fragment
func (FragmentSet) DebugOutput ¶ added in v1.11.0
func (self FragmentSet) DebugOutput() []byte
func (FragmentSet) Get ¶ added in v1.11.0
func (self FragmentSet) Get(name string) (*Fragment, bool)
func (FragmentSet) HasLayout ¶ added in v1.11.0
func (self FragmentSet) HasLayout() bool
func (FragmentSet) Header ¶ added in v1.11.0
func (self FragmentSet) Header(server *Server) TemplateHeader
func (*FragmentSet) Parse ¶ added in v1.11.0
func (self *FragmentSet) Parse(name string, source io.Reader) error
func (*FragmentSet) Set ¶ added in v1.11.0
func (self *FragmentSet) Set(name string, header *TemplateHeader, data []byte) error
type FuncMap ¶
type FuncMap map[string]interface{}
func GetFunctions ¶ added in v1.10.7
func GetStandardFunctions ¶
type HttpProtocol ¶ added in v1.11.3
type HttpProtocol struct { }
The HTTP binding protocol is used to interact with web servers and RESTful APIs. It is specified with URLs that use the http:// or https:// schemes.
func (*HttpProtocol) Retrieve ¶ added in v1.11.3
func (self *HttpProtocol) Retrieve(rr *ProtocolRequest) (*ProtocolResponse, error)
type MarkdownRenderer ¶ added in v1.9.20
type MarkdownRenderer struct {
// contains filtered or unexported fields
}
func (*MarkdownRenderer) Render ¶ added in v1.9.20
func (self *MarkdownRenderer) Render(w http.ResponseWriter, req *http.Request, options RenderOptions) error
func (*MarkdownRenderer) SetPrewriteFunc ¶ added in v1.11.0
func (self *MarkdownRenderer) SetPrewriteFunc(fn PrewriteFunc)
func (*MarkdownRenderer) SetServer ¶ added in v1.13.11
func (self *MarkdownRenderer) SetServer(server *Server)
func (*MarkdownRenderer) ShouldPrerender ¶ added in v1.9.22
func (self *MarkdownRenderer) ShouldPrerender() bool
type Mount ¶
type Mount interface { Open(string) (http.File, error) OpenWithType(string, *http.Request, io.Reader) (*MountResponse, error) WillRespondTo(string, *http.Request, io.Reader) bool GetMountPoint() string String() string }
func NewMountFromSpec ¶
type MountConfig ¶
type MountResponse ¶
type MountResponse struct { ContentType string StatusCode int Metadata map[string]interface{} RedirectTo string RedirectCode int // contains filtered or unexported fields }
func NewMountResponse ¶
func NewMountResponse(name string, size int64, payload interface{}) *MountResponse
func (*MountResponse) Close ¶
func (self *MountResponse) Close() error
func (*MountResponse) GetFile ¶
func (self *MountResponse) GetFile() http.File
func (*MountResponse) GetPayload ¶
func (self *MountResponse) GetPayload() interface{}
func (*MountResponse) IsDir ¶
func (self *MountResponse) IsDir() bool
func (*MountResponse) ModTime ¶
func (self *MountResponse) ModTime() time.Time
func (*MountResponse) Mode ¶
func (self *MountResponse) Mode() os.FileMode
func (*MountResponse) Name ¶
func (self *MountResponse) Name() string
func (*MountResponse) Readdir ¶
func (self *MountResponse) Readdir(count int) ([]os.FileInfo, error)
func (*MountResponse) Seek ¶
func (self *MountResponse) Seek(offset int64, whence int) (int64, error)
func (*MountResponse) Size ¶
func (self *MountResponse) Size() int64
func (*MountResponse) Sys ¶
func (self *MountResponse) Sys() interface{}
type OauthAuthenticator ¶ added in v1.10.10
type OauthAuthenticator struct {
// contains filtered or unexported fields
}
func NewOauthAuthenticator ¶ added in v1.10.10
func NewOauthAuthenticator(config *AuthenticatorConfig) (*OauthAuthenticator, error)
func (*OauthAuthenticator) Authenticate ¶ added in v1.10.10
func (self *OauthAuthenticator) Authenticate(w http.ResponseWriter, req *http.Request) bool
func (*OauthAuthenticator) Callback ¶ added in v1.10.10
func (self *OauthAuthenticator) Callback(w http.ResponseWriter, req *http.Request)
OAuth2: Leg 2: receive callback from consent page, validate session, and set session cookie
func (*OauthAuthenticator) IsCallback ¶ added in v1.10.10
func (self *OauthAuthenticator) IsCallback(u *url.URL) bool
func (*OauthAuthenticator) Name ¶ added in v1.11.0
func (self *OauthAuthenticator) Name() string
type PaginatorConfig ¶ added in v1.12.12
type PdfRenderer ¶ added in v1.9.20
type PdfRenderer struct {
// contains filtered or unexported fields
}
func (*PdfRenderer) Render ¶ added in v1.9.20
func (self *PdfRenderer) Render(w http.ResponseWriter, req *http.Request, options RenderOptions) error
func (*PdfRenderer) SetPrewriteFunc ¶ added in v1.11.0
func (self *PdfRenderer) SetPrewriteFunc(fn PrewriteFunc)
func (*PdfRenderer) SetServer ¶ added in v1.13.11
func (self *PdfRenderer) SetServer(server *Server)
func (*PdfRenderer) ShouldPrerender ¶ added in v1.9.22
func (self *PdfRenderer) ShouldPrerender() bool
type Performable ¶ added in v1.11.0
type Performable interface {
Perform(config *StepConfig, w http.ResponseWriter, req *http.Request, prev *StepConfig) (interface{}, error)
}
type PostprocessorFunc ¶
type PrewriteFunc ¶ added in v1.11.0
type ProcessStep ¶ added in v1.11.0
type ProcessStep struct{}
[type=process] Process the output of the previous step by performing a sequence of discrete
operations on the data.
-------------------------------------------------------------------------------------------------
func (*ProcessStep) Perform ¶ added in v1.11.0
func (self *ProcessStep) Perform(config *StepConfig, w http.ResponseWriter, req *http.Request, prev *StepConfig) (interface{}, error)
type Protocol ¶ added in v1.11.3
type Protocol interface {
Retrieve(*ProtocolRequest) (*ProtocolResponse, error)
}
type ProtocolConfig ¶ added in v1.11.3
type ProtocolConfig map[string]interface{}
type ProtocolRequest ¶ added in v1.11.3
type ProtocolRequest struct { Verb string URL *url.URL Binding *Binding Request *http.Request Header *TemplateHeader TemplateData map[string]interface{} TemplateFuncs FuncMap }
func (*ProtocolRequest) Conf ¶ added in v1.11.3
func (self *ProtocolRequest) Conf(proto string, key string, fallbacks ...interface{}) typeutil.Variant
func (*ProtocolRequest) Template ¶ added in v1.11.3
func (self *ProtocolRequest) Template(input interface{}) typeutil.Variant
type ProtocolResponse ¶ added in v1.11.3
type ProtocolResponse struct { MimeType string StatusCode int Raw interface{} // contains filtered or unexported fields }
func (*ProtocolResponse) Close ¶ added in v1.11.3
func (self *ProtocolResponse) Close() error
func (*ProtocolResponse) PeekLen ¶ added in v1.12.4
func (self *ProtocolResponse) PeekLen() (int64, error)
type ProxyMount ¶
type ProxyMount struct { MountPoint string `json:"-"` URL string `json:"-"` Method string `json:"method,omitempty"` Headers map[string]interface{} `json:"headers,omitempty"` ResponseHeaders map[string]interface{} `json:"response_headers,omitempty"` ResponseCode int `json:"response_code"` RedirectOnSuccess string `json:"redirect_on_success"` Params map[string]interface{} `json:"params,omitempty"` Timeout time.Duration `json:"timeout,omitempty"` PassthroughRequests bool `json:"passthrough_requests"` PassthroughErrors bool `json:"passthrough_errors"` StripPathPrefix string `json:"strip_path_prefix"` AppendPathPrefix string `json:"append_path_prefix"` Insecure bool `json:"insecure"` Client *http.Client // contains filtered or unexported fields }
func (*ProxyMount) GetMountPoint ¶
func (self *ProxyMount) GetMountPoint() string
func (*ProxyMount) OpenWithType ¶
func (self *ProxyMount) OpenWithType(name string, req *http.Request, requestBody io.Reader) (*MountResponse, error)
func (*ProxyMount) String ¶
func (self *ProxyMount) String() string
func (*ProxyMount) WillRespondTo ¶
type RedirectTo ¶
type RedirectTo string
func (RedirectTo) Error ¶
func (self RedirectTo) Error() string
type RedisProtocol ¶ added in v1.11.3
type RedisProtocol struct { }
The Redis binding protocol is used to retrieve or modify items in a Redis server. It is specified with URLs that use the redis://[host[:port]]/db/key scheme.
Protocol Options ¶
- redis.default_host (localhost:6379) Specifies the hostname:port to use if a resource URI does not specify one.
- redis.max_idle (10) The maximum number of idle connections to maintain in a connection pool.
- redis.idle_timeout (120s) The maximum idle time of a connection before it is closed.
- redis.max_lifetime (10m) The maximum amount of time a connection can remain open before being recycled.
func (*RedisProtocol) Retrieve ¶ added in v1.11.3
func (self *RedisProtocol) Retrieve(rr *ProtocolRequest) (*ProtocolResponse, error)
type RenderOptions ¶ added in v1.9.20
type RenderOptions struct { Header *TemplateHeader HeaderOffset int FunctionSet FuncMap Input io.ReadCloser Fragments FragmentSet Data map[string]interface{} MimeType string RequestedPath string Timeout time.Duration }
type Renderer ¶ added in v1.9.20
type Renderer interface { SetPrewriteFunc(PrewriteFunc) SetServer(*Server) Render(w http.ResponseWriter, req *http.Request, options RenderOptions) error ShouldPrerender() bool }
type RespondStep ¶ added in v1.12.9
type RespondStep struct{}
[type=respond] Configure the HTTP response headers and status. -------------------------------------------------------------------------------------------------
func (*RespondStep) Perform ¶ added in v1.12.9
func (self *RespondStep) Perform(config *StepConfig, w http.ResponseWriter, req *http.Request, prev *StepConfig) (interface{}, error)
type ResultsPage ¶ added in v1.12.12
type SassRenderer ¶ added in v1.10.3
type SassRenderer struct {
// contains filtered or unexported fields
}
func (*SassRenderer) Render ¶ added in v1.10.3
func (self *SassRenderer) Render(w http.ResponseWriter, req *http.Request, options RenderOptions) error
func (*SassRenderer) SetPrewriteFunc ¶ added in v1.11.0
func (self *SassRenderer) SetPrewriteFunc(fn PrewriteFunc)
func (*SassRenderer) SetServer ¶ added in v1.13.11
func (self *SassRenderer) SetServer(server *Server)
func (*SassRenderer) ShouldPrerender ¶ added in v1.10.3
func (self *SassRenderer) ShouldPrerender() bool
type Server ¶
type Server struct { // Exposes the location of the diecast binary BinPath string `json:"-"` // The host:port address the server is listening on Address string `json:"address"` // Top-level bindings that apply to every rendered template Bindings []Binding `json:"bindings"` // Specify a string to prefix all binding resource values that start with "/" BindingPrefix string `json:"bindingPrefix"` // The filesystem location where templates and files are served from RootPath string `json:"root"` // The path to the layouts template directory LayoutPath string `json:"layouts"` // The path to the errors template directory ErrorsPath string `json:"errors"` // Enables additional options for debugging applications. Caution: can expose secrets and other sensitive data. EnableDebugging bool `json:"debug"` // Disable emitting per-request Server-Timing headers to aid in tracing bottlenecks and performance issues. DisableTimings bool `json:"disableTimings"` // Specifies whether layouts are enabled EnableLayouts bool `json:"enableLayouts"` // If specified, all requests must be prefixed with this string. RoutePrefix string `json:"routePrefix"` // A set of glob patterns specifying which files will be rendered as templates. TemplatePatterns []string `json:"patterns"` // Allow for the programmatic addition of extra functions for use in templates. AdditionalFunctions template.FuncMap `json:"-"` // Whether to attempt to locate a local file matching the requested path before attempting to find a template. TryLocalFirst bool `json:"localFirst"` // The name of the template file to use when a directory is requested. IndexFile string `json:"indexFile"` // A file that must exist and be readable before starting the server. VerifyFile string `json:"verifyFile"` // The set of all registered mounts. Mounts []Mount `json:"-"` // A list of mount configurations read from the diecast.yml config file. MountConfigs []MountConfig `json:"mounts"` // A default header that all templates will inherit from. BaseHeader *TemplateHeader `json:"header"` DefaultPageObject map[string]interface{} `json:"-"` OverridePageObject map[string]interface{} `json:"-"` // A command that will be executed before the server is started. PrestartCommands []*StartCommand `json:"prestart"` // A command that will be executed after the server is confirmed running. StartCommands []*StartCommand `json:"start"` // Disable the execution of PrestartCommands and StartCommand . DisableCommands bool `json:"disable_commands"` // A set of authenticator configurations used to protect some or all routes. Authenticators AuthenticatorConfigs `json:"authenticators"` // Try these file extensions when looking for default (i.e.: "index") files. If IndexFile has an extension, it will be stripped first. TryExtensions []string `json:"tryExtensions"` // Map file extensions to preferred renderers for a given file type. RendererMappings map[string]string `json:"rendererMapping"` // Which types of files will automatically have layouts applied. AutolayoutPatterns []string `json:"autolayoutPatterns"` // List of filenames containing PEM-encoded X.509 TLS certificates that represent trusted authorities. // Use to validate certificates signed by an internal, non-public authority. TrustedRootPEMs []string `json:"trustedRootPEMs"` // Configure routes and actions to execute when those routes are requested. Actions []*Action `json:"actions"` // Specify that requests that terminate at a filesystem directory should automatically generate an index // listing of that directory. Autoindex bool `json:"autoindex"` // If Autoindex is enabled, this allows the template used to generate the index page to be customized. AutoindexTemplate string `json:"autoindex_template"` // Setup global configuration details for Binding Protocols Protocols map[string]ProtocolConfig `json:"protocols"` // A function that can be used to intercept handlers being added to the server. OnAddHandler AddHandlerFunc `json:"-"` // Stores translations for use with the i18n and l10n functions. Keys values represent the Translations map[string]interface{} `json:"translations,omitempty"` // Specify the default locale for pages being served. Locale string `json:"locale"` // Specify the environment for loading environment-specific configuration files in the form "diecast.env.yml" Environment string `json:"environment"` // TODO: favicon autogenerator // Specifies the relative path to the file containing the /favicon.ico file. This path can point to // a Windows Icon (.ico), GIF, PNG, JPEG, or Bitmap (.bmp). If necessary, the file will be converted // and stored in memory to the ICO format. FaviconPath string `json:"favicon"` // where SSL/TLS configuration is stored TLS *TlsConfig `json:"tls"` // a list of glob patterns matching environment variable names that should not be exposed FilterEnvVars []string `json:"filter_env_vars"` // a list of glob patterns matching environment variable names that should always be exposed ExposeEnvVars []string `json:"expose_env_vars"` // contains filtered or unexported fields }
func (*Server) Connect ¶ added in v1.11.7
func (self *Server) Connect(route string, handler http.HandlerFunc)
Add a handler for an HTTP CONNECT endpoint.
func (*Server) Delete ¶ added in v1.11.7
func (self *Server) Delete(route string, handler http.HandlerFunc)
Add a handler for an HTTP DELETE endpoint.
func (*Server) Get ¶ added in v1.11.7
func (self *Server) Get(route string, handler http.HandlerFunc)
Add a handler for an HTTP GET endpoint.
func (*Server) GetTemplateData ¶
func (*Server) GetTemplateFunctions ¶
func (self *Server) GetTemplateFunctions(data map[string]interface{}, header *TemplateHeader) FuncMap
Retrieves the set of standard template functions, as well as functions for working with data in the current request.
func (*Server) HandleFunc ¶ added in v1.11.7
func (self *Server) HandleFunc(route string, handler http.HandlerFunc)
Add a handler for an endpoint (any HTTP method.)
func (*Server) Head ¶ added in v1.11.7
func (self *Server) Head(route string, handler http.HandlerFunc)
Add a handler for an HTTP HEAD endpoint.
func (*Server) Initialize ¶
func (*Server) IsInRootPath ¶ added in v1.11.2
func (*Server) ListenAndServe ¶
func (*Server) LoadConfig ¶
func (*Server) Options ¶ added in v1.11.7
func (self *Server) Options(route string, handler http.HandlerFunc)
Add a handler for an HTTP OPTIONS endpoint.
func (*Server) P ¶ added in v1.11.7
Return the value of a URL parameter within a given request handler.
func (*Server) Patch ¶ added in v1.11.7
func (self *Server) Patch(route string, handler http.HandlerFunc)
Add a handler for an HTTP PATCH endpoint.
func (*Server) Post ¶ added in v1.11.7
func (self *Server) Post(route string, handler http.HandlerFunc)
Add a handler for an HTTP POST endpoint.
func (*Server) Put ¶ added in v1.11.7
func (self *Server) Put(route string, handler http.HandlerFunc)
Add a handler for an HTTP PUT endpoint.
func (*Server) RunStartCommand ¶
func (self *Server) RunStartCommand(scmds []*StartCommand, waitForCommand bool) (bool, error)
func (*Server) SetFileSystem ¶
func (self *Server) SetFileSystem(fs http.FileSystem)
func (*Server) ToTemplateName ¶
type ShellAuthenticator ¶ added in v1.11.0
type ShellAuthenticator struct {
// contains filtered or unexported fields
}
func NewShellAuthenticator ¶ added in v1.11.0
func NewShellAuthenticator(config *AuthenticatorConfig) (*ShellAuthenticator, error)
func (*ShellAuthenticator) Authenticate ¶ added in v1.11.0
func (self *ShellAuthenticator) Authenticate(w http.ResponseWriter, req *http.Request) bool
func (*ShellAuthenticator) Callback ¶ added in v1.11.0
func (self *ShellAuthenticator) Callback(w http.ResponseWriter, req *http.Request)
func (*ShellAuthenticator) IsCallback ¶ added in v1.11.0
func (self *ShellAuthenticator) IsCallback(_ *url.URL) bool
func (*ShellAuthenticator) Name ¶ added in v1.11.0
func (self *ShellAuthenticator) Name() string
type ShellStep ¶ added in v1.11.0
type ShellStep struct{}
[type=shell] Return the output of a command as a response. Valid Configurations
Command string passed to the user's $SHELL:
data: 'some shell command'
Command array executed via exec*() system calls:
data: ['command', '--arg', 'x=1', '--help']
Command options specified as an object:
data: command: # interpreted the same as above (string or array) inherit: true|false # whether the current shell environment should be inherited by the command env: X: abc Y: zyx
-------------------------------------------------------------------------------------------------
func (*ShellStep) Perform ¶ added in v1.11.0
func (self *ShellStep) Perform(config *StepConfig, w http.ResponseWriter, req *http.Request, prev *StepConfig) (interface{}, error)
type StartCommand ¶
type StaticAuthenticator ¶ added in v1.11.0
type StaticAuthenticator struct {
// contains filtered or unexported fields
}
func NewStaticAuthenticator ¶ added in v1.11.0
func NewStaticAuthenticator(config *AuthenticatorConfig, allow bool) (*StaticAuthenticator, error)
func (*StaticAuthenticator) Authenticate ¶ added in v1.11.0
func (self *StaticAuthenticator) Authenticate(w http.ResponseWriter, req *http.Request) bool
func (*StaticAuthenticator) Callback ¶ added in v1.11.0
func (self *StaticAuthenticator) Callback(w http.ResponseWriter, req *http.Request)
func (*StaticAuthenticator) IsCallback ¶ added in v1.11.0
func (self *StaticAuthenticator) IsCallback(_ *url.URL) bool
func (*StaticAuthenticator) Name ¶ added in v1.11.0
func (self *StaticAuthenticator) Name() string
type StepConfig ¶ added in v1.11.0
type StepConfig struct { Type string `json:"type"` Data interface{} `json:"data"` Timeout string `json:"timeout,omitempty"` Parser string `json:"parser"` Output interface{} `json:"-"` Error error `json:"-"` // contains filtered or unexported fields }
func (*StepConfig) Close ¶ added in v1.12.9
func (self *StepConfig) Close() error
func (*StepConfig) Perform ¶ added in v1.11.0
func (self *StepConfig) Perform(_ *StepConfig, w http.ResponseWriter, req *http.Request, prev *StepConfig) (interface{}, error)
func (*StepConfig) String ¶ added in v1.11.0
func (self *StepConfig) String() string
type SwitchCase ¶ added in v1.9.9
type Template ¶
type Template struct {
// contains filtered or unexported fields
}
func NewTemplate ¶
func (*Template) AddPostProcessors ¶
func (*Template) ParseFragments ¶ added in v1.11.0
func (self *Template) ParseFragments(fragments FragmentSet) error
func (*Template) ParseString ¶ added in v1.11.0
func (*Template) SetDelimiters ¶ added in v1.10.7
func (*Template) SetHeaderOffset ¶
func (*Template) SetPrewriteFunc ¶ added in v1.11.0
func (self *Template) SetPrewriteFunc(fn func())
type TemplateHeader ¶
type TemplateHeader struct { // An object that is accessible to this template (and all inheriting templates) under the `$.page` variable. Page map[string]interface{} `json:"page,omitempty"` // An array of remote URLs to to be retrieved (in order) and added to the `$.bindings` object. Bindings []Binding `json:"bindings,omitempty"` // An object containing default query string values that can be accessed via the `qs` function. Defaults map[string]string `json:"defaults,omitempty"` // An object containing default HTTP request header values that can be accessed via the `$.request.headers` variable. DefaultHeaders map[string]string `json:"default_headers,omitempty"` // Specifies an HTTP redirect should be performed when this page is accessed. Redirect *Redirect `json:"redirect,omitempty"` // Specify which template file to load in lieu of this one depending on which condition evaluates true first. Switch []*SwitchCase `json:"switch,omitempty"` // The name of the layout (in the _layouts folder) to apply to this template. Layout string `json:"layout,omitempty"` // An object specifying a custom name and path to other templates to include when evaluating this one. Includes map[string]string `json:"includes,omitempty"` Headers map[string]interface{} `json:"headers,omitempty"` UrlParams map[string]interface{} `json:"params,omitempty"` // An object containing names and expressions to add to a `$.flags` variable. FlagDefs map[string]interface{} `json:"flags,omitempty"` // An array of built-in postprocessors to apply to the output before being returned to the user. Postprocessors []string `json:"postprocessors,omitempty"` // The built-in renderer to use when generating the page. Renderer string `json:"renderer,omitempty"` // Stores translations for use with the i18n and l10n functions. Keys values represent the Translations map[string]interface{} `json:"translations,omitempty"` // Stores the locale used for this page. If Locale is set on multiple levels of rendering, // the last evaluated value is used. Locale string `json:"locale"` // Override the string used to join multiple values of the same query string parameter. QueryJoiner string `json:"query_joiner,omitempty"` // Override the string used to join multiple values of the same HTTP header. HeaderJoiner string `json:"header_joiner,omitempty"` // contains filtered or unexported fields }
func SplitTemplateHeaderContent ¶
func SplitTemplateHeaderContent(reader io.Reader) (*TemplateHeader, []byte, error)
func (*TemplateHeader) Merge ¶
func (self *TemplateHeader) Merge(other *TemplateHeader) (*TemplateHeader, error)
type TemplateRenderer ¶ added in v1.9.20
type TemplateRenderer struct {
// contains filtered or unexported fields
}
func (*TemplateRenderer) Render ¶ added in v1.9.20
func (self *TemplateRenderer) Render(w http.ResponseWriter, req *http.Request, options RenderOptions) error
func (*TemplateRenderer) SetPrewriteFunc ¶ added in v1.11.0
func (self *TemplateRenderer) SetPrewriteFunc(fn PrewriteFunc)
func (*TemplateRenderer) SetServer ¶ added in v1.13.11
func (self *TemplateRenderer) SetServer(server *Server)
func (*TemplateRenderer) ShouldPrerender ¶ added in v1.9.22
func (self *TemplateRenderer) ShouldPrerender() bool
type TlsConfig ¶ added in v1.13.10
type TlsConfig struct { // Whether to enable SSL/TLS on the server. Enable bool `json:"enable"` // path to a PEM-encoded (.crt) file containing the server's TLS public key. CertFile string `json:"cert"` // path to a PEM-encoded (.key) file containing the server's TLS private key. KeyFile string `json:"key"` // If set, TLS Client certificates will be requested/accepted. If set, may // be one of: "request", "any", "verify", "require" ClientCertMode string `json:"clients"` // Path to a PEM-encoded file containing the CA that client certificates are issued and verify against. ClientCAFile string `json:"clientCA"` }
Source Files
¶
- actions.go
- actions_steps_process.go
- actions_steps_respond.go
- actions_steps_shell.go
- authenticator.go
- authenticator_basic.go
- authenticator_oauth.go
- authenticator_shell.go
- authenticator_static.go
- binding.go
- docs.go
- favicon.go
- fragment.go
- functions.go
- functions_defs_codecs.go
- functions_defs_collections.go
- functions_defs_color.go
- functions_defs_compare.go
- functions_defs_convert.go
- functions_defs_crypto_rand.go
- functions_defs_html.go
- functions_defs_introspection.go
- functions_defs_math.go
- functions_defs_path.go
- functions_defs_string.go
- functions_defs_time.go
- functions_defs_types.go
- functions_docs_request.go
- functions_docs_vars.go
- header.go
- mount.go
- mount_file.go
- mount_proxy.go
- mount_response.go
- postprocessors.go
- protocol.go
- protocol_http.go
- protocol_redis.go
- renderers.go
- renderers_markdown.go
- renderers_pdf.go
- renderers_sass.go
- renderers_template.go
- server.go
- server_handlers.go
- static.go
- template.go
- timing.go
- util.go
- version.go