navitas

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

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

Go to latest
Published: Jun 8, 2024 License: Apache-2.0 Imports: 51 Imported by: 0

README

bmozi

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

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

type Encryption

type Encryption struct {
	Key []byte
}

func (*Encryption) Decrypt

func (e *Encryption) Decrypt(cryptoText string) (string, error)

func (*Encryption) Encrypt

func (e *Encryption) Encrypt(text string) (string, error)
type Navitas 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

	EncryptionKey string
	Cache         cache.Cache
	Scheduler     *cron.Cron
	Mail          mailer.Mail
	Server        Server
	FileSystems   map[string]interface{}
	S3            s3filesystem.S3
	SFTP          sftpfilesystem.SFTP
	WebDAV        webdavfilesystem.WebDAV
	Minio         miniofilesystem.Minio
	// contains filtered or unexported fields
}

Navitas is the overall type for the Navitas package. Members that are exported in this type are available to any application that uses it.

func (n *Navitas) BuildDSN() string

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

func (n *Navitas) CreateDirIfNotExist(path string) error
func (n *Navitas) CreateFileIfNotExists(path string) error
func (n *Navitas) DownloadFile(w http.ResponseWriter, r *http.Request, pathToFile, fileName string) error

DownloadFile downloads a file

func (n *Navitas) Error404(w http.ResponseWriter, r *http.Request)

Error404 returns page not found response

func (n *Navitas) Error500(w http.ResponseWriter, r *http.Request)

Error500 returns internal server error response

func (n *Navitas) ErrorForbidden(w http.ResponseWriter, r *http.Request)

ErrorForbidden returns a forbidden status message (client is known)

func (n *Navitas) ErrorStatus(w http.ResponseWriter, status int)

ErrorStatus returns a response with the supplied http status

func (n *Navitas) ErrorUnauthorized(w http.ResponseWriter, r *http.Request)

ErrorUnauthorized sends an unauthorized status (client is not known)

func (n *Navitas) FetchPage(pageURL string) *rod.Page
func (n *Navitas) Init(p initPaths) error
func (n *Navitas) ListenAndServe()

ListenAndServe starts the web server

func (n *Navitas) LoadTime(start time.Time)

LoadTime calculates function execution time. To use, add defer c.LoadTime(time.Now()) to the function body

func (n *Navitas) MigrateDownAll(dsn string) error
func (n *Navitas) MigrateForce(dsn string) error
func (n *Navitas) MigrateUp(dsn string) error
func (n *Navitas) New(rootPath string) error

New reads the .env file, creates our application config, populates the Navitas type with settings based on .env values, and creates necessary folders and files if they don't exist

func (n *Navitas) NoSurf(next http.Handler) http.Handler
func (n *Navitas) 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 (n *Navitas) RandomString(val int) string

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

func (n *Navitas) ReadJSON(w http.ResponseWriter, r *http.Request, data interface{}) error
func (n *Navitas) SelectElementByID(page *rod.Page, id string) *rod.Element
func (n *Navitas) SessionLoad(next http.Handler) http.Handler
func (n *Navitas) Steps(val int, dsn string) error
func (n *Navitas) TakeScreenShot(pageURL, testName string, w, h float64)
func (n *Navitas) UploadFile(r *http.Request, destination, field string, fs filesystems.FS) error
func (n *Navitas) Validator(data url.Values) *Validation
func (n *Navitas) WriteJSON(w http.ResponseWriter, status int, data interface{}, headers ...http.Header) error

WriteJSON writes json from arbitrary data

func (n *Navitas) WriteXML(w http.ResponseWriter, status int, data interface{}, headers ...http.Header) error

WriteXML writes xml from arbitrary data

type RPCServer

type RPCServer struct{}

func (*RPCServer) MaintenanceMode

func (r *RPCServer) MaintenanceMode(inMaintenanceMode bool, resp *string) error

type Server

type Server struct {
	ServerName string
	Port       string
	Secure     bool
	URL        string
}

type Validation

type Validation struct {
	Data   url.Values
	Errors map[string]string
}

func (*Validation) AddError

func (v *Validation) AddError(key, message string)

func (*Validation) Check

func (v *Validation) Check(ok bool, key, message string)

func (*Validation) Has

func (v *Validation) Has(field string, r *http.Request) bool

func (*Validation) IsDateISO

func (v *Validation) IsDateISO(field, value string)

func (*Validation) IsEmail

func (v *Validation) IsEmail(field, value string)

func (*Validation) IsFloat

func (v *Validation) IsFloat(field, value string)

func (*Validation) IsInt

func (v *Validation) IsInt(field, value string)

func (*Validation) NoSpaces

func (v *Validation) NoSpaces(field, value string)

func (*Validation) Required

func (v *Validation) Required(r *http.Request, fields ...string)

func (*Validation) Valid

func (v *Validation) Valid() bool

Jump to

Keyboard shortcuts

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