celeritas

package module
v0.0.0-...-af1769d Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2021 License: MIT Imports: 18 Imported by: 0

README

celeritas

Celeritas

Documentation

Index

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

func (c *Celeritas) BuildDSN() string

BuildDSN builds the datasource name for our database, and returns it as a string

func (*Celeritas) CreateDirIfNotExists

func (c *Celeritas) CreateDirIfNotExists(path string) error

CreateDirIfNotExist creates a new directory if it does not exist

func (*Celeritas) CreateFileIfNotExists

func (c *Celeritas) CreateFileIfNotExists(path string) error

CreateFileIfNotExists creates a new file at path if it does not exist

func (*Celeritas) Init

func (c *Celeritas) Init(p initPaths) error

Init creates necessary folders for our Celeritas application

func (*Celeritas) ListenAndServe

func (c *Celeritas) ListenAndServe()

ListenAndServe starts the web server

func (*Celeritas) New

func (c *Celeritas) New(rootPath string) error

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

func (c *Celeritas) OpenDB(dbType, dsn string) (*sql.DB, error)

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

func (c *Celeritas) RandomString(n int) string

RandomString generates a random string length n from values in the const randomString

func (*Celeritas) SessionLoad

func (c *Celeritas) SessionLoad(next http.Handler) http.Handler

type Database

type Database struct {
	DataType string
	Pool     *sql.DB
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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