Documentation ¶
Index ¶
- type AddPrefixPathFS
- type EmbedFileSystem
- type HTMLTemplateHandler
- type JSONMarshaler
- type Server
- func (s *Server) HandleSimpleFormCommand(cmd cmds.GlazeCommand, options ...glazed.HandleOption) gin.HandlerFunc
- func (s *Server) HandleSimpleQueryCommand(cmd cmds.GlazeCommand, options ...glazed.HandleOption) gin.HandlerFunc
- func (s *Server) HandleSimpleQueryOutputFileCommand(cmd cmds.GlazeCommand, outputFile string, fileName string, ...) gin.HandlerFunc
- func (s *Server) LookupTemplate(name ...string) (*template.Template, error)
- func (s *Server) Run(ctx context.Context) error
- type ServerOption
- func WithAddress(address string) ServerOption
- func WithAppendTemplateLookups(lookups ...render.TemplateLookup) ServerOption
- func WithDefaultParkaLookup() ServerOption
- func WithDefaultParkaStaticPaths() ServerOption
- func WithFailOption(err error) ServerOption
- func WithGzip() ServerOption
- func WithPort(port uint16) ServerOption
- func WithPrependTemplateLookups(lookups ...render.TemplateLookup) ServerOption
- func WithReplaceTemplateLookups(lookups ...render.TemplateLookup) ServerOption
- func WithStaticPaths(paths ...StaticPath) ServerOption
- type StaticPath
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddPrefixPathFS ¶ added in v0.2.23
type AddPrefixPathFS struct {
// contains filtered or unexported fields
}
AddPrefixPathFS is a helper wrapper that will a prefix to each incoming filename that is to be opened. This is useful for embedFS which will keep their prefix. For example, mounting the embed fs go:embed static will retain the static/* prefix, while the static gin handler will strip it.
func NewAddPrefixPathFS ¶ added in v0.2.23
func NewAddPrefixPathFS(fs fs.FS, prefix string) AddPrefixPathFS
NewAddPrefixPathFS creates a new AddPrefixPathFS that will add the given prefix to each file that is opened..
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
NewEmbedFileSystem will create a new EmbedFileSystem that will serve the given embed.FS under the given URL path. stripPrefix will be added to the beginning of all paths when looking up files in the embed.FS.
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 Server ¶
type Server struct { Router *gin.Engine StaticPaths []StaticPath TemplateLookups []render.TemplateLookup Port uint16 Address string }
Server is the main class that parka uses to serve static and templated content. It is a wrapper around gin.Engine.
It is meant to be quite flexible, allowing you to add static paths and template lookups that can provide different fs and template backends.
Router is the gin.Engine that is used to serve the content, and it is exposed so that you can use it as just a gin.Engine if you want to.
func NewServer ¶
func NewServer(options ...ServerOption) (*Server, error)
NewServer will create a new Server with the given options. This loads a fixed set of files and templates from the embed.FS. These files provide tailwind support for Markdown rendering and a standard index and base page template. NOTE(manuel, 2023-04-16) This is definitely ripe to be removed.
func (*Server) HandleSimpleFormCommand ¶ added in v0.2.4
func (s *Server) HandleSimpleFormCommand( cmd cmds.GlazeCommand, options ...glazed.HandleOption, ) gin.HandlerFunc
func (*Server) HandleSimpleQueryCommand ¶ added in v0.2.4
func (s *Server) HandleSimpleQueryCommand( cmd cmds.GlazeCommand, options ...glazed.HandleOption, ) gin.HandlerFunc
func (*Server) HandleSimpleQueryOutputFileCommand ¶ added in v0.2.13
func (s *Server) HandleSimpleQueryOutputFileCommand( cmd cmds.GlazeCommand, outputFile string, fileName string, options ...glazed.HandleOption, ) gin.HandlerFunc
func (*Server) LookupTemplate ¶
LookupTemplate will iterate through the template lookups until it finds one of the templates given in name.
type ServerOption ¶
func WithAddress ¶ added in v0.2.6
func WithAddress(address string) ServerOption
WithAddress will set the address that the server will listen on.
func WithAppendTemplateLookups ¶ added in v0.2.6
func WithAppendTemplateLookups(lookups ...render.TemplateLookup) ServerOption
WithAppendTemplateLookups will append the given template lookups to the list of lookups, but they will be found after whatever templates might already be in the list. This is great for providing fallback templates.
func WithDefaultParkaLookup ¶ added in v0.2.19
func WithDefaultParkaLookup() ServerOption
func WithDefaultParkaStaticPaths ¶ added in v0.2.19
func WithDefaultParkaStaticPaths() ServerOption
func WithFailOption ¶ added in v0.2.19
func WithFailOption(err error) ServerOption
func WithGzip ¶ added in v0.2.19
func WithGzip() ServerOption
func WithPort ¶ added in v0.2.6
func WithPort(port uint16) ServerOption
WithPort will set the port that the server will listen on.
func WithPrependTemplateLookups ¶ added in v0.2.6
func WithPrependTemplateLookups(lookups ...render.TemplateLookup) ServerOption
WithPrependTemplateLookups will prepend the given template lookups to the list of lookups, ensuring that they will be found before whatever templates might already be in the list.
func WithReplaceTemplateLookups ¶ added in v0.2.6
func WithReplaceTemplateLookups(lookups ...render.TemplateLookup) ServerOption
WithReplaceTemplateLookups will replace any existing template lookups with the given ones.
func WithStaticPaths ¶
func WithStaticPaths(paths ...StaticPath) ServerOption
WithStaticPaths will add the given static paths to the list of static paths. If a path with the same URL path already exists, it will be replaced.
type StaticPath ¶
type StaticPath struct {
// contains filtered or unexported fields
}
StaticPath allows you to serve static files from a http.FileSystem under a given URL path urlPath.
func NewStaticPath ¶
func NewStaticPath(fs http.FileSystem, urlPath string) StaticPath
NewStaticPath creates a new StaticPath that will serve files from the given http.FileSystem.