pkg

package
v0.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2023 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadTemplateFS

func LoadTemplateFS(_fs fs.FS, baseDir string, patterns ...string) (*template.Template, error)

func NewGinHandlerFromParkaHandlers added in v0.2.4

func NewGinHandlerFromParkaHandlers(
	cmd cmds.Command,
	handlers []ParkaHandlerFunc,
	pdHandler ParkaHandlerFunc,
	layersHandler ParkaHandlerFunc,
) gin.HandlerFunc

func RenderMarkdownTemplateToHTML

func RenderMarkdownTemplateToHTML(t *template.Template, data interface{}) (string, error)

func RenderMarkdownToHTML

func RenderMarkdownToHTML(rendered string) (string, 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

func (*EmbedFileSystem) Exists

func (e *EmbedFileSystem) Exists(prefix string, path string) bool

func (*EmbedFileSystem) Open

func (e *EmbedFileSystem) Open(name string) (http.File, error)

type JSONMarshaler

type JSONMarshaler interface {
	MarshalJSON() ([]byte, error)
}

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 HandleParsedLayersFromForm added in v0.2.4

func HandleParsedLayersFromForm(
	layers_ []layers.ParameterLayer,
	onlyDefined bool,
) ParkaHandlerFunc

func HandleParsedLayersFromQuery added in v0.2.4

func HandleParsedLayersFromQuery(
	layers_ []layers.ParameterLayer,
	onlyDefined bool,
) ParkaHandlerFunc

func HandleParsedParametersFromForm added in v0.2.4

func HandleParsedParametersFromForm(
	ps map[string]*parameters.ParameterDefinition,
	onlyDefined bool,
) ParkaHandlerFunc

func HandleParsedParametersFromQuery added in v0.2.4

func HandleParsedParametersFromQuery(
	ps map[string]*parameters.ParameterDefinition,
	onlyDefined bool,
) ParkaHandlerFunc

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

type Server

type Server struct {
	Router *gin.Engine

	StaticPaths     []StaticPath
	TemplateLookups []TemplateLookup
}

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,
	handlers ...ParkaHandlerFunc,
) gin.HandlerFunc

func (*Server) LookupTemplate

func (s *Server) LookupTemplate(name ...string) (*template.Template, error)

LookupTemplate will iterate through the template lookups until it finds one of the templates given in name.

func (*Server) Run

func (s *Server) Run() error

type ServerOption

type ServerOption = func(*Server)

func WithStaticPaths

func WithStaticPaths(paths ...StaticPath) ServerOption

func WithTemplateLookups

func WithTemplateLookups(lookups ...TemplateLookup) ServerOption

type StaticPath

type StaticPath struct {
	// contains filtered or unexported fields
}

func NewStaticPath

func NewStaticPath(fs http.FileSystem, urlPath string) StaticPath

type TemplateLookup

type TemplateLookup func(name ...string) (*template.Template, error)

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.

func LookupTemplateFromFS

func LookupTemplateFromFS(_fs fs.FS, baseDir string, patterns ...string) (TemplateLookup, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL