golazy.dev golazy.dev / lazyapp Index | Files

package lazyapp

import "golazy.dev/lazyapp"

Package lazyapp composes the framework packages into a runnable GoLazy application.

Most applications use lazyapp.New at the application boundary. It wires the application context, route scope, view renderer, helper registry, asset registry, session manager, metadata endpoints, optional control plane, middleware chain, and public asset fallback into one http.Handler.

The lower-level packages remain independently usable. Use lazyroutes directly for a route table, lazyview and lazycontroller for custom rendering flows, or lazyassets for standalone asset serving. Use lazyapp when those pieces should behave like a conventional GoLazy application.

Functions

func MustSub

func MustSub(fsys fs.FS, dir string) func() (fs.FS, error)

Types

type App

type App struct {
	Name		string
	Context		context.Context
	Dispatcher	*lazydispatch.Dispatcher
	Router		*lazyroutes.Scope
	Assets		*lazyassets.Registry
	Sessions	*lazysession.Manager
	ControlPlane	*lazycontrolplane.ControlPlane
}
func New
func New(config Config) *App
func (app *App) ListenAndServe

ListenAndServe starts the app server on ADDR, PORT, or :3000.

It installs app.Context as the server base context, so every request context includes the dependencies initialized by New. When using a custom http.Server, set BaseContext to return app.Context.

func (app *App) ListenAndServe() error
func (app *App) ServeHTTP
func (app *App) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Config

type Config struct {
	Name	string
	Drawer	func(*lazyroutes.Scope)
	Public	func() (fs.FS, error)
	Views	func() (fs.FS, error)
	// Context may be func(context.Context) context.Context or
	// func(context.Context) (context.Context, error). The error-returning form is
	// preferred for new applications.
	Context			any
	Helpers			Helpers
	SEO			[]lazyseo.Option
	Assets			[]lazyassets.Source
	AssetOptions		[]lazyassets.Option
	Robots			RobotsConfig
	Sitemap			SitemapConfig
	Sessions		lazysession.Config
	ControlPlane		lazycontrolplane.Builder
	Middlewares		[]lazydispatch.Middleware
	ForceDetailErrors	bool
}

type RobotsRule

type RobotsRule struct {
	UserAgent	string
	Allow		[]string
	Disallow	[]string
	CrawlDelay	string
}