Documentation ¶
Index ¶
- func LoadTemplateFS(_fs fs.FS, baseDir string, patterns ...string) (*template.Template, error)
- func NewGinHandlerFromParkaHandlers(cmd cmds.Command, handlers ...ParkaHandlerFunc) gin.HandlerFunc
- func RenderMarkdownTemplateToHTML(t *template.Template, data interface{}) (string, error)
- func RenderMarkdownToHTML(rendered string) (string, error)
- func SetupProcessor(pc *ParkaContext) (*cmds.GlazeProcessor, formatters.OutputFormatter, error)
- type EmbedFileSystem
- type HTMLTemplateHandler
- type JSONMarshaler
- type ParameterDefinitionParser
- type ParkaContext
- type ParkaHandlerFunc
- type ParserHandler
- type ParserHandlerOption
- func WithCustomizedParameterLayerParser(l layers.ParameterLayer, overrides map[string]interface{}) ParserHandlerOption
- func WithGlazeOutputParserOption(gl *cli.GlazedParameterLayers, output string, tableFormat string) ParserHandlerOption
- func WithPostParameterDefinitionParser(ps ...ParameterDefinitionParser) ParserHandlerOption
- func WithPostParameterLayerParser(slug string, ps ...ParameterDefinitionParser) ParserHandlerOption
- func WithPreParameterDefinitionParsers(ps ...ParameterDefinitionParser) ParserHandlerOption
- func WithPreParameterLayerParser(slug string, ps ...ParameterDefinitionParser) ParserHandlerOption
- func WithReplaceParameterDefinitionParser(ps ...ParameterDefinitionParser) ParserHandlerOption
- func WithReplaceParameterLayerParser(slug string, ps ...ParameterDefinitionParser) ParserHandlerOption
- type Server
- func (s *Server) HandleSimpleFormCommand(cmd cmds.Command, handlers ...ParkaHandlerFunc) gin.HandlerFunc
- func (s *Server) HandleSimpleQueryCommand(cmd cmds.Command, parserOptions []ParserHandlerOption, ...) gin.HandlerFunc
- func (s *Server) LookupTemplate(name ...string) (*template.Template, error)
- func (s *Server) Run() error
- type ServerOption
- func WithAddress(address string) ServerOption
- func WithAppendTemplateLookups(lookups ...TemplateLookup) ServerOption
- func WithPort(port uint16) ServerOption
- func WithPrependTemplateLookups(lookups ...TemplateLookup) ServerOption
- func WithReplaceTemplateLookups(lookups ...TemplateLookup) ServerOption
- func WithStaticPaths(paths ...StaticPath) ServerOption
- type StaticPath
- type TemplateLookup
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadTemplateFS ¶
func NewGinHandlerFromParkaHandlers ¶ added in v0.2.4
func NewGinHandlerFromParkaHandlers( cmd cmds.Command, handlers ...ParkaHandlerFunc, ) gin.HandlerFunc
func RenderMarkdownToHTML ¶
func SetupProcessor ¶
func SetupProcessor(pc *ParkaContext) (*cmds.GlazeProcessor, formatters.OutputFormatter, error)
Types ¶
type EmbedFileSystem ¶
type EmbedFileSystem struct {
// contains filtered or unexported fields
}
EmbedFileSystem is a helper to make an embed FS work as a http.FS, which allows us to serve embed.FS using gin's `Static` middleware.
func NewEmbedFileSystem ¶
func NewEmbedFileSystem(f fs.FS, stripPrefix string) *EmbedFileSystem
type HTMLTemplateHandler ¶ added in v0.2.6
HTMLTemplateHandler is a handler that renders a template and also provides affordances to control what input parameters are passed downstream Its main purpose is to be used as a fragment renderer for htmx calls
type JSONMarshaler ¶
type ParameterDefinitionParser ¶ added in v0.2.6
type ParameterDefinitionParser func( c *gin.Context, ps map[string]interface{}, pds map[string]*parameters.ParameterDefinition, ) (map[string]*parameters.ParameterDefinition, error)
ParameterDefinitionParser can be used to intercept parsing certain values. If a parameter shouldn't be handled by a follow up step, return a new hashmap with the key deleted
func NewStaticLayerParameterDefinitionParser ¶ added in v0.2.6
func NewStaticLayerParameterDefinitionParser(l layers.ParameterLayer) ParameterDefinitionParser
func NewStaticParameterDefinitionParser ¶ added in v0.2.6
func NewStaticParameterDefinitionParser(ps map[string]interface{}) ParameterDefinitionParser
type ParkaContext ¶ added in v0.2.4
type ParkaContext struct { // Cmd is the command that will be executed Cmd cmds.Command // ParsedLayers contains the map of parsed layers parsed so far ParsedLayers map[string]*layers.ParsedParameterLayer // ParsedParameters contains the map of parsed parameters parsed so far ParsedParameters map[string]interface{} }
ParkaContext keeps the context for execution of a parka command, and can be worked upon by ParkaHandlerFuncs.
func NewParkaContext ¶ added in v0.2.4
func NewParkaContext(cmd cmds.Command) *ParkaContext
type ParkaHandlerFunc ¶ added in v0.2.4
type ParkaHandlerFunc func(*gin.Context, *ParkaContext) error
func HandlePrepopulatedParameters ¶ added in v0.2.4
func HandlePrepopulatedParameters(ps map[string]interface{}) ParkaHandlerFunc
func HandlePrepopulatedParsedLayers ¶ added in v0.2.4
func HandlePrepopulatedParsedLayers(layers_ map[string]*layers.ParsedParameterLayer) ParkaHandlerFunc
func WithCommandParser ¶ added in v0.2.6
func WithCommandParser(cmd cmds.Command, parserHandler *ParserHandler) ParkaHandlerFunc
type ParserHandler ¶ added in v0.2.6
type ParserHandler struct { ParameterDefinitionParsers []ParameterDefinitionParser ParameterLayerParsersBySlug map[string][]ParameterDefinitionParser }
func NewFormParserHandler ¶ added in v0.2.6
func NewFormParserHandler(cmd cmds.Command, options ...ParserHandlerOption) *ParserHandler
func NewParserHandler ¶ added in v0.2.6
func NewParserHandler(options ...ParserHandlerOption) *ParserHandler
func NewQueryParserHandler ¶ added in v0.2.6
func NewQueryParserHandler(cmd cmds.Command, options ...ParserHandlerOption) *ParserHandler
type ParserHandlerOption ¶ added in v0.2.6
type ParserHandlerOption func(*ParserHandler)
func WithCustomizedParameterLayerParser ¶ added in v0.2.6
func WithCustomizedParameterLayerParser(l layers.ParameterLayer, overrides map[string]interface{}) ParserHandlerOption
func WithGlazeOutputParserOption ¶ added in v0.2.6
func WithGlazeOutputParserOption(gl *cli.GlazedParameterLayers, output string, tableFormat string) ParserHandlerOption
func WithPostParameterDefinitionParser ¶ added in v0.2.6
func WithPostParameterDefinitionParser(ps ...ParameterDefinitionParser) ParserHandlerOption
func WithPostParameterLayerParser ¶ added in v0.2.6
func WithPostParameterLayerParser(slug string, ps ...ParameterDefinitionParser) ParserHandlerOption
func WithPreParameterDefinitionParsers ¶ added in v0.2.6
func WithPreParameterDefinitionParsers(ps ...ParameterDefinitionParser) ParserHandlerOption
func WithPreParameterLayerParser ¶ added in v0.2.6
func WithPreParameterLayerParser(slug string, ps ...ParameterDefinitionParser) ParserHandlerOption
func WithReplaceParameterDefinitionParser ¶ added in v0.2.6
func WithReplaceParameterDefinitionParser(ps ...ParameterDefinitionParser) ParserHandlerOption
func WithReplaceParameterLayerParser ¶ added in v0.2.6
func WithReplaceParameterLayerParser(slug string, ps ...ParameterDefinitionParser) ParserHandlerOption
type Server ¶
type Server struct { Router *gin.Engine StaticPaths []StaticPath TemplateLookups []TemplateLookup Port uint16 Address string }
func NewServer ¶
func NewServer(options ...ServerOption) (*Server, error)
func (*Server) HandleSimpleFormCommand ¶ added in v0.2.4
func (s *Server) HandleSimpleFormCommand( cmd cmds.Command, handlers ...ParkaHandlerFunc, ) gin.HandlerFunc
func (*Server) HandleSimpleQueryCommand ¶ added in v0.2.4
func (s *Server) HandleSimpleQueryCommand( cmd cmds.Command, parserOptions []ParserHandlerOption, handlers ...ParkaHandlerFunc, ) gin.HandlerFunc
func (*Server) LookupTemplate ¶
LookupTemplate will iterate through the template lookups until it finds one of the templates given in name.
type ServerOption ¶
type ServerOption = func(*Server)
func WithAddress ¶ added in v0.2.6
func WithAddress(address string) ServerOption
func WithAppendTemplateLookups ¶ added in v0.2.6
func WithAppendTemplateLookups(lookups ...TemplateLookup) ServerOption
func WithPort ¶ added in v0.2.6
func WithPort(port uint16) ServerOption
func WithPrependTemplateLookups ¶ added in v0.2.6
func WithPrependTemplateLookups(lookups ...TemplateLookup) ServerOption
func WithReplaceTemplateLookups ¶ added in v0.2.6
func WithReplaceTemplateLookups(lookups ...TemplateLookup) ServerOption
func WithStaticPaths ¶
func WithStaticPaths(paths ...StaticPath) ServerOption
type StaticPath ¶
type StaticPath struct {
// contains filtered or unexported fields
}
func NewStaticPath ¶
func NewStaticPath(fs http.FileSystem, urlPath string) StaticPath
type TemplateLookup ¶
func LookupTemplateFromDirectory ¶
func LookupTemplateFromDirectory(dir string) TemplateLookup
LookupTemplateFromDirectory will load a template at runtime. This is useful for testing local changes to templates without having to recompile the app.