Documentation ¶
Index ¶
- func NewHandlerParametersFromLayerParams(p *LayerParams)
- type Command
- type CommandDir
- type Config
- type DefaultRendererOptions
- type Defaults
- type HandlerParameters
- type LayerParams
- type OverridesAndDefaults
- type OverridesAndDefaultsOption
- func WithDefaultArgument(name string, value string) OverridesAndDefaultsOption
- func WithDefaultFlag(name string, value string) OverridesAndDefaultsOption
- func WithLayerDefaults(name string, layer map[string]interface{}) OverridesAndDefaultsOption
- func WithMergeDefaultLayer(name string, layer *layers.ParsedParameterLayer) OverridesAndDefaultsOption
- func WithMergeDefaults(defaults *HandlerParameters) OverridesAndDefaultsOption
- func WithMergeOverrideLayer(name string, layer map[string]interface{}) OverridesAndDefaultsOption
- func WithMergeOverrides(overrides *HandlerParameters) OverridesAndDefaultsOption
- func WithOverrideArgument(name string, value string) OverridesAndDefaultsOption
- func WithOverrideFlag(name string, value string) OverridesAndDefaultsOption
- func WithReplaceDefaultLayer(name string, layer map[string]interface{}) OverridesAndDefaultsOption
- func WithReplaceDefaults(defaults *HandlerParameters) OverridesAndDefaultsOption
- func WithReplaceOverrideLayer(name string, layer map[string]interface{}) OverridesAndDefaultsOption
- func WithReplaceOverrides(overrides *HandlerParameters) OverridesAndDefaultsOption
- type Route
- func (r *Route) HandlesCommand() bool
- func (r *Route) HandlesStatic() bool
- func (r *Route) HandlesTemplate() bool
- func (r *Route) IsCommandDirRoute() bool
- func (r *Route) IsCommandRoute() bool
- func (r *Route) IsStaticFileRoute() bool
- func (r *Route) IsStaticRoute() bool
- func (r *Route) IsTemplateDirRoute() bool
- func (r *Route) IsTemplateRoute() bool
- type RouteHandlerConfiguration
- type Static
- type StaticFile
- type Template
- type TemplateDir
- type TemplateLookupConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHandlerParametersFromLayerParams ¶ added in v0.4.6
func NewHandlerParametersFromLayerParams(p *LayerParams)
NewHandlerParametersFromLayerParams creates a new HandlerParameters from the config file. It currently requires a list of layerDefinitions in order to lookup the correct layers to stored as ParsedParameterLayer. It doesn't fail if configured layers don't exist.
TODO(manuel, 2023-05-31) Add a way to validate the fact that overrides in a config file might have a typo and don't correspond to existing layer definitions in the application.
Types ¶
type Command ¶
type Command struct { File string `yaml:"file"` TemplateName string `yaml:"templateName"` TemplateLookup *TemplateLookupConfig `yaml:"templateLookup,omitempty"` AdditionalData map[string]interface{} `yaml:"additionalData,omitempty"` Defaults *LayerParams `yaml:"defaults,omitempty"` Overrides *LayerParams `yaml:"overrides,omitempty"` Stream *bool `yaml:"stream,omitempty"` }
func (*Command) ExpandPaths ¶
type CommandDir ¶
type CommandDir struct { Repositories []string `yaml:"repositories"` IncludeDefaultRepositories *bool `yaml:"includeDefaultRepositories"` TemplateLookup *TemplateLookupConfig `yaml:"templateLookup,omitempty"` TemplateName string `yaml:"templateName,omitempty"` IndexTemplateName string `yaml:"indexTemplateName,omitempty"` AdditionalData map[string]interface{} `yaml:"additionalData,omitempty"` Defaults *LayerParams `yaml:"defaults,omitempty"` Overrides *LayerParams `yaml:"overrides,omitempty"` Stream *bool `yaml:"stream,omitempty"` }
CommandDir represents the config file entry for a command directory route.
func (*CommandDir) ExpandPaths ¶
func (c *CommandDir) ExpandPaths() error
type Config ¶
type Config struct { Routes []*Route `yaml:"routes"` Defaults *Defaults `yaml:"defaults,omitempty"` }
func ParseConfig ¶
func (*Config) Initialize ¶ added in v0.3.2
type DefaultRendererOptions ¶ added in v0.3.2
type DefaultRendererOptions struct { UseDefaultParkaRenderer *bool `yaml:"useDefaultParkaRenderer,omitempty"` // TODO(manuel, 2023-06-21) These two options are not implemented yet // It is not so much that they are hard to implement, but rather that they are annoying to test. // See: https://github.com/go-go-golems/parka/issues/56 TemplateDirectory string `yaml:"templateDirectory,omitempty"` MarkdownBaseTemplateName string `yaml:"markdownBaseTemplateName,omitempty"` }
DefaultRendererOptions controls the default renderer. If UseDefaultParkaRenderer is true, the default parka renderer will be used. It renders markdown files using base.tmpl.html and uses a tailwind css stylesheet which has to be served under dist/output.css.
type Defaults ¶ added in v0.3.2
type Defaults struct { Renderer *DefaultRendererOptions `yaml:"renderer,omitempty"` UseParkaStaticFiles *bool `yaml:"useParkaStaticFiles,omitempty"` }
Defaults controls the default renderer and which embedded static files to serve.
type HandlerParameters ¶ added in v0.4.6
type HandlerParameters struct { Layers map[string]map[string]interface{} Flags map[string]interface{} Arguments map[string]interface{} }
func NewHandlerParameters ¶ added in v0.4.6
func NewHandlerParameters() *HandlerParameters
func (*HandlerParameters) Merge ¶ added in v0.4.6
func (ho *HandlerParameters) Merge(other *HandlerParameters)
Merge merges the given overrides into this one. If a layer is already present, it is merged with the given one. Flags and arguments are merged, overrides taking precedence.
type LayerParams ¶
type LayerParams struct { Layers map[string]map[string]interface{} `yaml:"layers,omitempty"` Flags map[string]interface{} `yaml:"flags,omitempty"` Arguments map[string]interface{} `yaml:"arguments,omitempty"` }
func NewLayerParams ¶
func NewLayerParams() *LayerParams
func (*LayerParams) Merge ¶
func (p *LayerParams) Merge(overrides *LayerParams)
Merge merges the two LayerParams, with the overrides taking precedence. It merges all the layers, flags, and arguments. For each layer, the layer flags are merged as well, overrides taking precedence.
type OverridesAndDefaults ¶ added in v0.4.6
type OverridesAndDefaults struct { Overrides *HandlerParameters Defaults *HandlerParameters }
func (*OverridesAndDefaults) ComputeParserOptions ¶ added in v0.4.6
func (od *OverridesAndDefaults) ComputeParserOptions(stream bool) []parser.ParserOption
type OverridesAndDefaultsOption ¶ added in v0.4.6
type OverridesAndDefaultsOption func(*OverridesAndDefaults)
func WithDefaultArgument ¶ added in v0.4.6
func WithDefaultArgument(name string, value string) OverridesAndDefaultsOption
func WithDefaultFlag ¶ added in v0.4.6
func WithDefaultFlag(name string, value string) OverridesAndDefaultsOption
func WithLayerDefaults ¶ added in v0.4.6
func WithLayerDefaults(name string, layer map[string]interface{}) OverridesAndDefaultsOption
WithLayerDefaults populates the defaults for the given layer. If a value is already set, the value is skipped.
func WithMergeDefaultLayer ¶ added in v0.4.6
func WithMergeDefaultLayer(name string, layer *layers.ParsedParameterLayer) OverridesAndDefaultsOption
func WithMergeDefaults ¶ added in v0.4.6
func WithMergeDefaults(defaults *HandlerParameters) OverridesAndDefaultsOption
func WithMergeOverrideLayer ¶ added in v0.4.6
func WithMergeOverrideLayer(name string, layer map[string]interface{}) OverridesAndDefaultsOption
func WithMergeOverrides ¶ added in v0.4.6
func WithMergeOverrides(overrides *HandlerParameters) OverridesAndDefaultsOption
func WithOverrideArgument ¶ added in v0.4.6
func WithOverrideArgument(name string, value string) OverridesAndDefaultsOption
func WithOverrideFlag ¶ added in v0.4.6
func WithOverrideFlag(name string, value string) OverridesAndDefaultsOption
func WithReplaceDefaultLayer ¶ added in v0.4.6
func WithReplaceDefaultLayer(name string, layer map[string]interface{}) OverridesAndDefaultsOption
func WithReplaceDefaults ¶ added in v0.4.6
func WithReplaceDefaults(defaults *HandlerParameters) OverridesAndDefaultsOption
func WithReplaceOverrideLayer ¶ added in v0.4.6
func WithReplaceOverrideLayer(name string, layer map[string]interface{}) OverridesAndDefaultsOption
func WithReplaceOverrides ¶ added in v0.4.6
func WithReplaceOverrides(overrides *HandlerParameters) OverridesAndDefaultsOption
type Route ¶
type Route struct { Path string `yaml:"path"` CommandDirectory *CommandDir `yaml:"commandDirectory,omitempty"` Command *Command `yaml:"command,omitempty"` Static *Static `yaml:"static,omitempty"` StaticFile *StaticFile `yaml:"staticFile,omitempty"` TemplateDirectory *TemplateDir `yaml:"templateDirectory,omitempty"` Template *Template `yaml:"template,omitempty"` }
Route represents a single sub-route of the server. Only one of the booleans or one of the pointers should be true or non-nil. This is the first attempt at the structure of a config file, and is bound to change.
func (*Route) HandlesCommand ¶
func (*Route) HandlesStatic ¶
func (*Route) HandlesTemplate ¶
func (*Route) IsCommandDirRoute ¶
func (*Route) IsCommandRoute ¶
func (*Route) IsStaticFileRoute ¶
func (*Route) IsStaticRoute ¶
func (*Route) IsTemplateDirRoute ¶
func (*Route) IsTemplateRoute ¶
type RouteHandlerConfiguration ¶
type RouteHandlerConfiguration interface { // ExpandPaths() error }
RouteHandlerConfiguration is the interface that all route handler configurations must implement. By RouteHandlerConfiguration, we mean things like CommandDir, Command, Static, etc...
type Static ¶
type Static struct {
LocalPath string `yaml:"localPath"`
}
func (*Static) ExpandPaths ¶
type StaticFile ¶
type StaticFile struct {
LocalPath string `yaml:"localPath"`
}
func (*StaticFile) ExpandPaths ¶
func (s *StaticFile) ExpandPaths() error
type Template ¶
type Template struct { // every request will be rendered from the template file, using the default renderer in the case of markdown // content. TemplateFile string `yaml:"templateFile"` AdditionalData map[string]interface{} `yaml:"additionalData,omitempty"` }
func (*Template) ExpandPaths ¶
type TemplateDir ¶
type TemplateDir struct { LocalDirectory string `yaml:"localDirectory"` IndexTemplateName string `yaml:"indexTemplateName,omitempty"` AdditionalData map[string]interface{} `yaml:"additionalData,omitempty"` }
TemplateDir serves a directory of html, md, .tmpl.md, .tmpl.html files. Markdown files are renderer using the given MarkdownBaseTemplateName, which will be looked up in the TemplateDir itself, or using the default renderer if empty.
func (*TemplateDir) ExpandPaths ¶
func (t *TemplateDir) ExpandPaths() error
type TemplateLookupConfig ¶ added in v0.3.2
type TemplateLookupConfig struct { // Directories is a list of directories that will be searched for templates. Directories []string `yaml:"directories,omitempty"` // Patterns is a list of glob patterns that will be used to match files in the directories. // If the list is empty, the default of **/*.tmpl.md and **/*.tmpl.html will be used Patterns []string `yaml:"patterns,omitempty"` }
TemplateLookupConfig is used to configured a directory based template lookup.