Documentation ¶
Index ¶
- func GetDefaultParkaRendererOptions() ([]render.RendererOption, error)
- func GetParkaStaticFS() http.FileSystem
- 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) Run(ctx context.Context) error
- type ServerOption
- func WithAddress(address string) ServerOption
- func WithDefaultParkaLookup(options ...render.RendererOption) ServerOption
- func WithDefaultParkaStaticPaths() ServerOption
- func WithDefaultRenderer(r *render.Renderer) ServerOption
- func WithFailOption(err error) ServerOption
- func WithGzip() ServerOption
- func WithPort(port uint16) ServerOption
- func WithStaticPaths(paths ...StaticPath) ServerOption
- type StaticPath
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDefaultParkaRendererOptions ¶ added in v0.2.28
func GetDefaultParkaRendererOptions() ([]render.RendererOption, error)
func GetParkaStaticFS ¶ added in v0.2.28
func GetParkaStaticFS() http.FileSystem
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 DefaultRenderer *render.Renderer 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
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 WithDefaultParkaLookup ¶ added in v0.2.19
func WithDefaultParkaLookup(options ...render.RendererOption) ServerOption
func WithDefaultParkaStaticPaths ¶ added in v0.2.19
func WithDefaultParkaStaticPaths() ServerOption
func WithDefaultRenderer ¶ added in v0.2.28
func WithDefaultRenderer(r *render.Renderer) 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 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.