Documentation
¶
Overview ¶
Package handler provides the HTTP handlers for the Defacto2 website. Using the Echo web framework, the handler is the entry point for the web server.
Index ¶
- Constants
- Variables
- func EmbedDirs(e *echo.Echo, currentFs fs.FS) *echo.Echo
- func MovedPermanently(e *echo.Echo) *echo.Echo
- type Configuration
- func (c *Configuration) Controller(db *sql.DB, sl *slog.Logger) *echo.Echo
- func (c *Configuration) FilesRoutes(e *echo.Echo, db *sql.DB, sl *slog.Logger, public embed.FS) (*echo.Echo, error)
- func (c *Configuration) NoCrawl(next echo.HandlerFunc) echo.HandlerFunc
- func (c *Configuration) PortErr(sl *slog.Logger, port uint16, err error)
- func (c *Configuration) ReadOnlyLock(next echo.HandlerFunc, sl *slog.Logger) echo.HandlerFunc
- func (c *Configuration) Registry(db *sql.DB, sl *slog.Logger) (*TemplateRegistry, error)
- func (c *Configuration) RequestLoggerConfig(sl *slog.Logger) middleware.RequestLoggerConfig
- func (c *Configuration) SessionLock(next echo.HandlerFunc, sl *slog.Logger) echo.HandlerFunc
- func (c *Configuration) ShutdownHTTP(w io.Writer, e *echo.Echo, sl *slog.Logger)
- func (c *Configuration) Start(e *echo.Echo, sl *slog.Logger, configs config.Config) error
- func (c *Configuration) StartHTTP(e *echo.Echo, sl *slog.Logger)
- func (c *Configuration) StartTLS(e *echo.Echo, sl *slog.Logger)
- func (c *Configuration) StartTLSLocal(e *echo.Echo, sl *slog.Logger)
- func (c *Configuration) StartupBranding(sl *slog.Logger, w io.Writer)
- type TemplateRegistry
Constants ¶
const ( // ShutdownCounter is the number of iterations to wait before shutting down the server. ShutdownCounter = 3 // ShutdownWait is the number of seconds to wait before shutting down the server. ShutdownWait = ShutdownCounter * time.Second // Downloader is the route for the file download handler. Downloader = "/d/:id" )
Variables ¶
Functions ¶
func MovedPermanently ¶
func MovedPermanently(e *echo.Echo) *echo.Echo
MovedPermanently redirects are partial URL routers that are to be redirected with a HTTP 301 Moved Permanently.
Types ¶
type Configuration ¶
type Configuration struct { Public embed.FS // Public facing files. View embed.FS // View contains Go templates. Version string // Version is the results of GoReleaser build command. Brand []byte // Brand contains the Defacto2 ASCII logo. Environment config.Config // Environment configurations from the host system. RecordCount int // The total number of file records in the database. }
Configuration of the handler.
func (*Configuration) Controller ¶
func (c *Configuration) Controller(db *sql.DB, sl *slog.Logger) *echo.Echo
Controller is the primary instance of the Echo router.
func (*Configuration) FilesRoutes ¶
func (c *Configuration) FilesRoutes(e *echo.Echo, db *sql.DB, sl *slog.Logger, public embed.FS, ) (*echo.Echo, error)
FilesRoutes defines the file locations and routes for the web server.
func (*Configuration) NoCrawl ¶
func (c *Configuration) NoCrawl(next echo.HandlerFunc) echo.HandlerFunc
NoCrawl middleware adds a `X-Robots-Tag` header to the response. The header contains the noindex and nofollow values that tell search engine crawlers to not index or crawl the page or asset. See https://developers.google.com/search/docs/crawling-indexing/robots-meta-tag#xrobotstag
func (*Configuration) PortErr ¶
func (c *Configuration) PortErr(sl *slog.Logger, port uint16, err error)
PortErr handles the error when the HTTP or HTTPS server cannot start.
func (*Configuration) ReadOnlyLock ¶
func (c *Configuration) ReadOnlyLock(next echo.HandlerFunc, sl *slog.Logger) echo.HandlerFunc
ReadOnlyLock disables all PATCH, POST, PUT and DELETE requests for the modification of the database and any related user interface.
func (*Configuration) Registry ¶
func (c *Configuration) Registry(db *sql.DB, sl *slog.Logger) (*TemplateRegistry, error)
Registry returns the template renderer.
func (*Configuration) RequestLoggerConfig ¶ added in v1.8.0
func (c *Configuration) RequestLoggerConfig(sl *slog.Logger) middleware.RequestLoggerConfig
RequestLoggerConfig handles logging for HTTP page requests. A slog Logger is required otherwise it will panic.
If Configuration.LogAll is false then this returns a nil. Otherwise it logs all web server HTTP requests to info logs.
func (*Configuration) SessionLock ¶
func (c *Configuration) SessionLock(next echo.HandlerFunc, sl *slog.Logger) echo.HandlerFunc
SessionLock middleware checks the session cookie for a valid signed in client.
func (*Configuration) ShutdownHTTP ¶
func (c *Configuration) ShutdownHTTP(w io.Writer, e *echo.Echo, sl *slog.Logger)
ShutdownHTTP waits for a Ctrl-C keyboard press to initiate a graceful shutdown of the HTTP web server. The shutdown procedure occurs a few seconds after the key press.
func (*Configuration) StartHTTP ¶
func (c *Configuration) StartHTTP(e *echo.Echo, sl *slog.Logger)
StartHTTP starts the insecure HTTP web server.
func (*Configuration) StartTLS ¶
func (c *Configuration) StartTLS(e *echo.Echo, sl *slog.Logger)
StartTLS starts the encrypted TLS web server.
func (*Configuration) StartTLSLocal ¶
func (c *Configuration) StartTLSLocal(e *echo.Echo, sl *slog.Logger)
StartTLSLocal starts the localhost, encrypted TLS web server. This should only be triggered when the server is running in local mode.
func (*Configuration) StartupBranding ¶ added in v1.8.0
func (c *Configuration) StartupBranding(sl *slog.Logger, w io.Writer)
StartupBranding prints the application logo and information to the w io.writer.
type TemplateRegistry ¶
TemplateRegistry is template registry struct.
Directories
¶
Path | Synopsis |
---|---|
Package app handles the routes and views for the Defacto2 website.
|
Package app handles the routes and views for the Defacto2 website. |
internal/filerecord
Package filerecord provides functions for the file model which is an artifact record.
|
Package filerecord provides functions for the file model which is an artifact record. |
internal/fileslice
Package fileslice provides functions that return model FileSlices, which are multiple artifact records.
|
Package fileslice provides functions that return model FileSlices, which are multiple artifact records. |
internal/simple
Package simple provides functions for handling string or integer input data.
|
Package simple provides functions for handling string or integer input data. |
remote
Package remote provides the remote download and update of artifact data from third-party sources such as API's.
|
Package remote provides the remote download and update of artifact data from third-party sources such as API's. |
Package areacode provides information about North American Numbering Plan telephone area codes.
|
Package areacode provides information about North American Numbering Plan telephone area codes. |
Package cache provides a lightweight engine for storing key/value pairs.
|
Package cache provides a lightweight engine for storing key/value pairs. |
Package demozoo handles the retrieval of [production records] from the [Demozoo] API and the extraction of relevant data for the Defacto2 website.
|
Package demozoo handles the retrieval of [production records] from the [Demozoo] API and the extraction of relevant data for the Defacto2 website. |
Package download handles the client file downloads.
|
Package download handles the client file downloads. |
Package form provides functions for providing data for form and input elements.
|
Package form provides functions for providing data for form and input elements. |
Package html3 renders the html3 sub-route of the website.
|
Package html3 renders the html3 sub-route of the website. |
ext
Package ext contains common filename extensions used by the file records.
|
Package ext contains common filename extensions used by the file records. |
Package htmx handles the routes and views for the AJAX responses using the htmx library.
|
Package htmx handles the routes and views for the AJAX responses using the htmx library. |
Package jsdos configures the js-dos v6.22 emulator.
|
Package jsdos configures the js-dos v6.22 emulator. |
msdos
Package msdos provides functions for working with MS-DOS FAT 12/16 file system filenames.
|
Package msdos provides functions for working with MS-DOS FAT 12/16 file system filenames. |
Package pouet provides production, user voting data sourced from the Pouet website API.
|
Package pouet provides production, user voting data sourced from the Pouet website API. |
Package readme provides functions for reading and suggesting readme files.
|
Package readme provides functions for reading and suggesting readme files. |
Package render provides the file content rendering for the web server.
|
Package render provides the file content rendering for the web server. |
Package sess provides functions for handling session and cookies.
|
Package sess provides functions for handling session and cookies. |
Package site proves links and titles for recommended websites.
|
Package site proves links and titles for recommended websites. |
Package sixteen provides data about releasers and groups on the 16colors website.
|
Package sixteen provides data about releasers and groups on the 16colors website. |
Package tidbit offers hyperlinked historical information about the Scene releasers and groups.
|
Package tidbit offers hyperlinked historical information about the Scene releasers and groups. |