Documentation ¶
Index ¶
- type Celeritas
- func (c *Celeritas) BuildDSN() string
- func (c *Celeritas) CreateDirIfNotExists(path string) error
- func (c *Celeritas) CreateFileIfNotExists(path string) error
- func (c *Celeritas) Init(p initPaths) error
- func (c *Celeritas) ListenAndServe()
- func (c *Celeritas) New(rootPath string) error
- func (c *Celeritas) OpenDB(dbType, dsn string) (*sql.DB, error)
- func (c *Celeritas) RandomString(n int) string
- func (c *Celeritas) SessionLoad(next http.Handler) http.Handler
- type Database
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Celeritas ¶
type Celeritas struct { AppName string Debug bool Version string ErrorLog *log.Logger InfoLog *log.Logger RootPath string Routes *chi.Mux Render *render.Render Session *scs.SessionManager DB Database JetViews *jet.Set // contains filtered or unexported fields }
Celeritas is the overall type for the Celeritas package. Members that are exported in this type are available to any application that uses it.
func (*Celeritas) BuildDSN ¶
BuildDSN builds the datasource name for our database, and returns it as a string
func (*Celeritas) CreateDirIfNotExists ¶
CreateDirIfNotExist creates a new directory if it does not exist
func (*Celeritas) CreateFileIfNotExists ¶
CreateFileIfNotExists creates a new file at path if it does not exist
func (*Celeritas) ListenAndServe ¶
func (c *Celeritas) ListenAndServe()
ListenAndServe starts the web server
func (*Celeritas) New ¶
New reads the .env file, creates our application config, populates the Celeritas type with settings based on .env values, and creates necessary folders and files if they don't exist
func (*Celeritas) OpenDB ¶
OpenDB opens a connection to a sql database. dbType must be one of postgres (or pgx). TODO: add support for mysql/mariadb
func (*Celeritas) RandomString ¶
RandomString generates a random string length n from values in the const randomString