Documentation ¶
Overview ¶
* A resuable app framework.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Validator *validator.Validate // validates variables and structs to enforce rules
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct { Router *chi.Mux DB *pgxpool.Pool ThemeName string ThemeRoot string Version string Slug string LoggingLevel *slog.LevelVar // contains filtered or unexported fields }
* App represents the overall state of the application and what makes it unique, * particularly when it comes to environment variables. The database connection * and log level in particular and tracked here.
func NewApp ¶
func NewApp(appName, dbUser, dbPassword, dbHost string, dbPort int, dbName string, opts ...AppOption) (*App, error)
* NewApp returns a new instance of App with many of its fields initialized. * Zero or more AppOptions may be provided to customize default values. * * The called of this function should defer close the DB connection.
type AppOption ¶
type AppOption func(*App)
* AppOption customizes how an App is configured via the constructor.
type BaseModel ¶
type BaseModel struct { DB *pgxpool.Pool `db:"-"` ID uint64 `db:"id"` CreatedTime time.Time `db:"created_time",json:"created_time"` UpdatedTime time.Time `db:"updated_time",json:"updated_time"` }
* BaseModel defines the minimum that all models should contain in terms of * fields. It's intended to be used with the Model interface.
type Flash ¶
* Flash represents a cross-page message to the user. It typically appears once * and then is erased.
type Model ¶
type Model interface { // just a timesaver IDString() // contains filtered or unexported methods }
* A model represents structured data that can undergo standard CRUD operations * with a PostgreSQL database. * * As the current plan is not to create an ORM, this interface is around to * simply help reduce boilerplate and for programmers to remember what their * models should have in terms of methods. * * Models implementing this interface should use the suffix `Model` and should * embed BaseModel.