application

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serve

func Serve(views fs.FS, opts ...Option)

Types

type AccessCheck

type AccessCheck func(*App, http.ResponseWriter, *http.Request) bool

type App

type App struct {
	// contains filtered or unexported fields
}

func New

func New(views fs.FS, opts ...Option) *App

func (*App) Protect

func (app *App) Protect(h http.Handler, accessCheck AccessCheck) http.HandlerFunc

func (*App) ProtectFunc

func (app *App) ProtectFunc(fn http.HandlerFunc, accessLevel AccessCheck) http.HandlerFunc

func (*App) Render

func (app *App) Render(w io.Writer, r *http.Request, page string, data any)

Render renders a view with given data to the http writer

func (*App) Serve

func (app *App) Serve(name string, accessCheck AccessCheck) *View

func (*App) Server

func (app *App) Server() (string, http.Handler)

func (*App) Service

func (app *App) Service() Service

func (*App) SetTheme added in v1.2.1

func (app *App) SetTheme(theme string)

SetTheme updates the application theme

func (*App) Start

func (app *App) Start() error

Start runs the application HTTP server and SSL server

func (App) Use

func (app App) Use(name string) Controller

Use returns the controller with the given name

func (*App) WithController

func (app *App) WithController(name string, controller Controller) error

WithController adds a controller to the application

func (*App) WithViews

func (app *App) WithViews(source fs.FS) error

WithViews adds views directory to application

type BaseController

type BaseController struct {
	*App
	*http.Request
}

func (*BaseController) Atoi

func (c *BaseController) Atoi(name string, defaultValue int) int

func (*BaseController) EventStream

func (c *BaseController) EventStream(w http.ResponseWriter, r *http.Request) (func(string, any), error)

func (*BaseController) Redirect

func (c *BaseController) Redirect(w http.ResponseWriter, r *http.Request, path string)

func (*BaseController) Refresh

func (c *BaseController) Refresh(w http.ResponseWriter, r *http.Request)

func (*BaseController) RenderError added in v1.3.0

func (c *BaseController) RenderError(w http.ResponseWriter, r *http.Request, err error)

func (*BaseController) RenderErrorMsg added in v1.3.0

func (c *BaseController) RenderErrorMsg(w http.ResponseWriter, r *http.Request, msg string)

func (*BaseController) Setup

func (base *BaseController) Setup(app *App)

func (*BaseController) Use

func (base *BaseController) Use(name string) Controller

type Controller

type Controller interface {
	Setup(*App)
	Handle(*http.Request) Controller
}

type Model

type Model = database.Model

Model is a type alias for database.Model to make our code cleaner when reviewing

type Option

type Option func(*App) error

Option is a function that configures an Application

func WithController

func WithController(name string, ctrl Controller) Option

WithController adds a controller to the application

func WithDaisyTheme

func WithDaisyTheme(theme string) Option

WithDaisyTheme sets the theme for the views

func WithFunc

func WithFunc(name string, fn any) Option

WithFunc adds a template function to the application

func WithHostPrefix

func WithHostPrefix(prefix string) Option

WithHostPrefix sets the host prefix for the views

func WithViews

func WithViews(views fs.FS) Option

WithViews adds views directory to application

type Service

type Service struct {
	*App
}

type View

type View struct {
	// contains filtered or unexported fields
}

func (*View) Render

func (v *View) Render(w http.ResponseWriter, r *http.Request, data any)

func (*View) ServeHTTP

func (v *View) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL