Documentation ¶
Index ¶
- func CustomHTTPErrorHandler(err error, c echo.Context)
- func GetDefaultParkaRendererOptions() ([]render.RendererOption, error)
- func GetDefaultParkaTemplateLookup() (render.TemplateLookup, error)
- func GetParkaStaticFS() fs.FS
- func GetParkaStaticHttpFS() fs.FS
- type Server
- type ServerOption
- func WithAddress(address string) ServerOption
- func WithDefaultParkaRenderer(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 ...utils_fs.StaticPath) ServerOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CustomHTTPErrorHandler ¶ added in v0.5.6
func CustomHTTPErrorHandler(err error, c echo.Context)
func GetDefaultParkaRendererOptions ¶
func GetDefaultParkaRendererOptions() ([]render.RendererOption, error)
GetDefaultParkaRendererOptions will return the default options for the parka renderer. This includes looking up templates from the embedded templateFS to provide support for markdown rendering with tailwind. This includes css files. It also sets base.tmpl.html as the base template for wrapping rendered markdown.
func GetDefaultParkaTemplateLookup ¶ added in v0.3.2
func GetDefaultParkaTemplateLookup() (render.TemplateLookup, error)
func GetParkaStaticFS ¶
func GetParkaStaticHttpFS ¶ added in v0.3.2
Types ¶
type Server ¶
type Server struct { Router *echo.Echo // TODO(manuel, 2023-06-05) This should become a standard Static handler to be added to the Routes StaticPaths []utils_fs.StaticPath // TODO(manuel, 2023-06-05) This could potentially be replaced with a fallback Handler 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) RegisterDebugRoutes ¶ added in v0.4.4
func (s *Server) RegisterDebugRoutes()
type ServerOption ¶
func WithAddress ¶
func WithAddress(address string) ServerOption
WithAddress will set the address that the server will listen on.
func WithDefaultParkaRenderer ¶
func WithDefaultParkaRenderer(options ...render.RendererOption) ServerOption
func WithDefaultParkaStaticPaths ¶
func WithDefaultParkaStaticPaths() ServerOption
func WithDefaultRenderer ¶
func WithDefaultRenderer(r *render.Renderer) ServerOption
func WithFailOption ¶
func WithFailOption(err error) ServerOption
func WithGzip ¶
func WithGzip() ServerOption
func WithPort ¶
func WithPort(port uint16) ServerOption
WithPort will set the port that the server will listen on.
func WithStaticPaths ¶
func WithStaticPaths(paths ...utils_fs.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.