Documentation ¶
Index ¶
- func NewCommandFormParser(cmd cmds.GlazeCommand, options ...parser.ParserOption) *parser.Parser
- func NewCommandQueryParser(cmd cmds.GlazeCommand, options ...parser.ParserOption) *parser.Parser
- type CommandContext
- type ContextMiddleware
- type ContextParserMiddleware
- type PrepopulatedContextMiddleware
- type PrepopulatedParsedLayersContextMiddleware
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCommandFormParser ¶
func NewCommandFormParser(cmd cmds.GlazeCommand, options ...parser.ParserOption) *parser.Parser
func NewCommandQueryParser ¶
func NewCommandQueryParser(cmd cmds.GlazeCommand, options ...parser.ParserOption) *parser.Parser
Types ¶
type CommandContext ¶
type CommandContext struct { // Cmd is the command that will be executed Cmd cmds.GlazeCommand // 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{} }
CommandContext keeps the context for execution of a glazed command, and can be worked upon by CommandHandlerFunc.
A CommandContext is progressively built up from the query by passing through a list of registered ParkaHandlerFuncs. These handler functions are registered to a specific route.
func NewCommandContext ¶
func NewCommandContext(cmd cmds.GlazeCommand) *CommandContext
NewCommandContext creates a new CommandContext for the given command.
func (*CommandContext) GetAllParameterDefinitions ¶
func (pc *CommandContext) GetAllParameterDefinitions() []*parameters.ParameterDefinition
GetAllParameterDefinitions returns a map of all parameter definitions for the command. This includes flags, arguments and all layers.
func (*CommandContext) GetAllParameterValues ¶
func (pc *CommandContext) GetAllParameterValues() map[string]interface{}
func (*CommandContext) GetFlagsAndArgumentsParameterDefinitions ¶
func (pc *CommandContext) GetFlagsAndArgumentsParameterDefinitions() []*parameters.ParameterDefinition
type ContextMiddleware ¶ added in v0.4.1
type ContextMiddleware interface {
Handle(*gin.Context, *CommandContext) error
}
ContextMiddleware is used to build up a CommandContext. It is similar to the HandlerFunc in gin, but instead of handling the HTTP response, it is only used to build up the CommandContext.
type ContextParserMiddleware ¶ added in v0.4.1
type ContextParserMiddleware struct {
// contains filtered or unexported fields
}
func NewContextParserMiddleware ¶ added in v0.4.1
func NewContextParserMiddleware(cmd cmds.GlazeCommand, parser *parser.Parser) *ContextParserMiddleware
func (*ContextParserMiddleware) Handle ¶ added in v0.4.1
func (cpm *ContextParserMiddleware) Handle(c *gin.Context, pc *CommandContext) error
type PrepopulatedContextMiddleware ¶ added in v0.4.1
type PrepopulatedContextMiddleware struct {
// contains filtered or unexported fields
}
PrepopulatedContextMiddleware is a ContextMiddleware that prepopulates the CommandContext with the given map of parameters. It overwrites existing parameters in pc.ParsedParameters, and overwrites parameters in individual parser layers if they have already been set.
func NewPrepopulatedContextMiddleware ¶ added in v0.4.1
func NewPrepopulatedContextMiddleware(ps map[string]interface{}) *PrepopulatedContextMiddleware
func (*PrepopulatedContextMiddleware) Handle ¶ added in v0.4.1
func (p *PrepopulatedContextMiddleware) Handle(c *gin.Context, pc *CommandContext) error
type PrepopulatedParsedLayersContextMiddleware ¶ added in v0.4.1
type PrepopulatedParsedLayersContextMiddleware struct {
// contains filtered or unexported fields
}
PrepopulatedParsedLayersContextMiddleware is a ContextMiddleware that prepopulates the CommandContext with the given map of layers. If a layer already exists, it overwrites its parameters.
func NewPrepopulatedParsedLayersContextMiddleware ¶ added in v0.4.1
func NewPrepopulatedParsedLayersContextMiddleware( layers map[string]*layers.ParsedParameterLayer, ) *PrepopulatedParsedLayersContextMiddleware
func (*PrepopulatedParsedLayersContextMiddleware) Handle ¶ added in v0.4.1
func (p *PrepopulatedParsedLayersContextMiddleware) Handle(c *gin.Context, pc *CommandContext) error