Documentation ¶
Overview ¶
Package godest provides a mildly opinionated framework for more easily writing web apps with modest Javascript approaches, especially with the Hotwire libraries. It provides support for using templates in a clear and structured way. It also makes it easy to embed all templates, static assets (e.g. images) and app-related assets (e.g. JS bundles) into the compiled server binary, and it takes care of the details of browser caching for assets and templated pages. Finally, it provides some standalone utilities for caching data on the server, getting the values of environment variables, and using cookies for form-based authentication.
Index ¶
- func ComputeCSPHash(resource []byte) string
- func HandleFS(routePrefix string, fsys fs.FS, age time.Duration) http.Handler
- func HandleFSFileRevved(routePrefix string, fsys fs.FS) http.Handler
- type EchoRouter
- type Embeds
- type HeaderOption
- type Inlines
- type Logger
- type RenderData
- type TemplateRenderer
- func (tr TemplateRenderer) CacheablePage(w http.ResponseWriter, r *http.Request, templateName string, ...) error
- func (tr TemplateRenderer) MustHave(templateNames ...string)
- func (tr TemplateRenderer) Page(w http.ResponseWriter, r *http.Request, status int, templateName string, ...) error
- func (tr TemplateRenderer) TurboStream(w http.ResponseWriter, messages ...turbostreams.Message) error
- func (tr TemplateRenderer) WritePartial(w io.Writer, partialName string, partialData interface{}) error
- func (tr TemplateRenderer) WriteTurboStream(w io.Writer, messages ...turbostreams.Message) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeCSPHash ¶ added in v0.4.3
Types ¶
type EchoRouter ¶
type EchoRouter interface { CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route }
EchoRouter is a simple interface which specifies echo.Route addition functions which are present on both echo.Echo and echo.Group, since we want to allow using either of them for path registration.
type Embeds ¶
type Embeds struct { StaticFS fs.FS StaticHFS *hashfs.FS TemplatesFS fs.FS AppFS fs.FS AppHFS *hashfs.FS FontsFS fs.FS }
func (Embeds) GetAppHashedNamer ¶
type HeaderOption ¶
func WithAlwaysRevalidate ¶
func WithAlwaysRevalidate() HeaderOption
func WithContentType ¶
func WithContentType(contentType string) HeaderOption
func WithRevalidateWhenStale ¶
func WithRevalidateWhenStale(maxAge int) HeaderOption
func WithUncacheable ¶
func WithUncacheable() HeaderOption
type Inlines ¶
type Inlines struct { CSS map[string]template.CSS JS map[string]template.JS JSStr map[string]template.JSStr HTML map[string]template.HTML HTMLAttr map[string]template.HTMLAttr SrcSet map[string]template.Srcset }
func (Inlines) ComputeCSSHashesForCSP ¶
func (Inlines) ComputeJSHashesForCSP ¶
type Logger ¶
type Logger interface { Print(i ...interface{}) Printf(format string, args ...interface{}) Debug(i ...interface{}) Debugf(format string, args ...interface{}) Info(i ...interface{}) Infof(format string, args ...interface{}) Warn(i ...interface{}) Warnf(format string, args ...interface{}) Error(i ...interface{}) Errorf(format string, args ...interface{}) Fatal(i ...interface{}) Fatalf(format string, args ...interface{}) Panic(i ...interface{}) Panicf(format string, args ...interface{}) }
Logger is a reduced interface for loggers.
type RenderData ¶
type TemplateRenderer ¶
type TemplateRenderer struct {
// contains filtered or unexported fields
}
func NewTemplateRenderer ¶
func NewTemplateRenderer( e Embeds, inlines interface{}, funcs ...template.FuncMap, ) (tr TemplateRenderer, err error)
func (TemplateRenderer) CacheablePage ¶
func (tr TemplateRenderer) CacheablePage( w http.ResponseWriter, r *http.Request, templateName string, templateData interface{}, authData interface{}, headerOptions ...HeaderOption, ) error
func (TemplateRenderer) MustHave ¶
func (tr TemplateRenderer) MustHave(templateNames ...string)
func (TemplateRenderer) Page ¶
func (tr TemplateRenderer) Page( w http.ResponseWriter, r *http.Request, status int, templateName string, templateData interface{}, authData interface{}, headerOptions ...HeaderOption, ) error
func (TemplateRenderer) TurboStream ¶
func (tr TemplateRenderer) TurboStream( w http.ResponseWriter, messages ...turbostreams.Message, ) error
func (TemplateRenderer) WritePartial ¶
func (tr TemplateRenderer) WritePartial( w io.Writer, partialName string, partialData interface{}, ) error
func (TemplateRenderer) WriteTurboStream ¶
func (tr TemplateRenderer) WriteTurboStream(w io.Writer, messages ...turbostreams.Message) error
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package actioncable provides a server-side implementation of the Rails Action Cable protocol (https://docs.anycable.io/misc/action_cable_protocol)
|
Package actioncable provides a server-side implementation of the Rails Action Cable protocol (https://docs.anycable.io/misc/action_cable_protocol) |
Package authn provides a high-level client for user authentication
|
Package authn provides a high-level client for user authentication |
Package clientcache provides support for caching requests as a client
|
Package clientcache provides support for caching requests as a client |
Package database provides a high-level relational database interface with schema migration, connection pooling, prepared statement, and embedded query support, wrapping around zombiezen.com/go/sqlite's CGo-free sqlite interface
|
Package database provides a high-level relational database interface with schema migration, connection pooling, prepared statement, and embedded query support, wrapping around zombiezen.com/go/sqlite's CGo-free sqlite interface |
Package env contains code for handling environment variables
|
Package env contains code for handling environment variables |
Package handling provides utilities for handlers and background workers
|
Package handling provides utilities for handlers and background workers |
Package httperr provides utilities for writing human-readable HTTP error page templates.
|
Package httperr provides utilities for writing human-readable HTTP error page templates. |
Package marshaling provides a uniform thread-safe interface to various encoding/decoding formats such as Gob, JSON, and MessagePack, following the JSON marshal/unmarshal function interface.
|
Package marshaling provides a uniform thread-safe interface to various encoding/decoding formats such as Gob, JSON, and MessagePack, following the JSON marshal/unmarshal function interface. |
Package middleware provides middleware functionality not provided by other packages.
|
Package middleware provides middleware functionality not provided by other packages. |
Package opa provides a high-level client for using embedded Rego policies with OPA
|
Package opa provides a high-level client for using embedded Rego policies with OPA |
Package pubsub provides pub-sub functionality.
|
Package pubsub provides pub-sub functionality. |
Package session standardizes session management with Gorilla sessions
|
Package session standardizes session management with Gorilla sessions |
memstore
Package memstore provides an in-RAM (non-persistent) session store
|
Package memstore provides an in-RAM (non-persistent) session store |
sqlitestore
Package sqlitestore store provides a sqlite-backed session store using [database.DB]
|
Package sqlitestore store provides a sqlite-backed session store using [database.DB] |
Package turbostreams provides server-side support for sending Hotwired Turbo Streams in POST responses as well as over Action Cable.
|
Package turbostreams provides server-side support for sending Hotwired Turbo Streams in POST responses as well as over Action Cable. |