fenix

package module
v0.0.0-...-6fb5550 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 License: MIT Imports: 57 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Routes

func Routes() http.Handler

Routes are fenix specific routes that are mounted in the routes file

Types

type Database

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

type Encryption

type Encryption struct {
	Key []byte
}

func (*Encryption) Decrypt

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

func (*Encryption) Encrypt

func (e *Encryption) Encrypt(text string) (string, error)

type Fenix

type Fenix 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
}

func (*Fenix) BuildDSN

func (f *Fenix) BuildDSN() string

BuildDSN builds the datasource name of the database, then returns as a string

func (*Fenix) CheckForMaintenanceMode

func (f *Fenix) CheckForMaintenanceMode(next http.Handler) http.Handler

func (*Fenix) CreateDirIfNotExist

func (f *Fenix) CreateDirIfNotExist(path string) error

func (*Fenix) CreateFileIfNotExists

func (f *Fenix) CreateFileIfNotExists(path string) error

func (*Fenix) CreatePopMigration

func (f *Fenix) CreatePopMigration(up, down []byte, migrationName, migrationType string) error

CreatePopMigration is a wrapper for pop that writes contents for the given migration

func (*Fenix) DownloadFile

func (f *Fenix) DownloadFile(w http.ResponseWriter, r *http.Request, pathToFile, fileName string) error

Download file

func (*Fenix) ErrorBadRequest

func (f *Fenix) ErrorBadRequest(w http.ResponseWriter, r *http.Request)

Status 400 - Bad Request: The server cannot process the request due to a client error, such as invalid syntax or missing parameters.

func (*Fenix) ErrorForbidden

func (f *Fenix) ErrorForbidden(w http.ResponseWriter, r *http.Request)

Status 403 - Forbidden: The server understands the request, but the client is not allowed to access the requested resource.

func (*Fenix) ErrorIntServerErr

func (f *Fenix) ErrorIntServerErr(w http.ResponseWriter, r *http.Request)

Status 500 - Internal Server Error: The server encountered an unexpected condition that prevented it from fulfilling the request.

func (*Fenix) ErrorMethodNotAllowed

func (f *Fenix) ErrorMethodNotAllowed(w http.ResponseWriter, r *http.Request)

Status 405 - Method Not Allowed: The request method is not supported for the requested resource.

func (*Fenix) ErrorNotFound

func (f *Fenix) ErrorNotFound(w http.ResponseWriter, r *http.Request)

Status 404 - Not Found: The server could not find the requested resource.

func (*Fenix) ErrorServiceUnavailable

func (f *Fenix) ErrorServiceUnavailable(w http.ResponseWriter, r *http.Request)

Status 503 - Service Unavailable: The server is currently unavailable, often due to maintenance or overload.

func (*Fenix) ErrorStatus

func (f *Fenix) ErrorStatus(w http.ResponseWriter, status int)

Error status helper function

func (*Fenix) ErrorUnauthorized

func (f *Fenix) ErrorUnauthorized(w http.ResponseWriter, r *http.Request)

Status 401 - Unauthorized: The request requires authentication, and the client does not provide valid credentials.

func (*Fenix) FetchPage

func (f *Fenix) FetchPage(pageURL string) *rod.Page

func (*Fenix) Init

func (f *Fenix) Init(p initPaths) error

initializes the necessary folders for Fenix

func (*Fenix) ListenAndServe

func (f *Fenix) ListenAndServe() error

func (*Fenix) LoadTime

func (f *Fenix) LoadTime(start time.Time)

func (*Fenix) MigrateDownAll

func (f *Fenix) MigrateDownAll(dsn string) error

func (*Fenix) MigrateForce

func (f *Fenix) MigrateForce(dsn string) error

func (*Fenix) MigrateUp

func (f *Fenix) MigrateUp(dsn string) error

func (*Fenix) New

func (f *Fenix) New(rootPath string) error

func (*Fenix) NoSurf

func (f *Fenix) NoSurf(next http.Handler) http.Handler

func (*Fenix) OpenDB

func (f *Fenix) OpenDB(dbType, dsn string) (*sql.DB, error)

func (*Fenix) PopConnect

func (f *Fenix) PopConnect() (*pop.Connection, error)

popConnect connects to the buffalo/pop library to leverage multiple db migrations

func (*Fenix) PopMigrateReset

func (f *Fenix) PopMigrateReset(tx *pop.Connection) error

is a wrapper that resets the migration, runs down the migration in reverse order and migrations up

func (*Fenix) PopMigrationDown

func (f *Fenix) PopMigrationDown(tx *pop.Connection, steps ...int) error

PopMigrationDown is a wrapper that migrates down to roll back to previous db

func (*Fenix) RandomString

func (f *Fenix) RandomString(n int) (string, error)

func (*Fenix) ReadJSON

func (f *Fenix) ReadJSON(w http.ResponseWriter, r *http.Request, data interface{}) error

func (*Fenix) RunPopMigrations

func (f *Fenix) RunPopMigrations(tx *pop.Connection) error

RunPopMigrations is wrapper for pop to migrate up one or more migrations

func (*Fenix) SelectElementByID

func (f *Fenix) SelectElementByID(page *rod.Page, id string) *rod.Element

func (*Fenix) SessionLoad

func (f *Fenix) SessionLoad(next http.Handler) http.Handler

func (*Fenix) Steps

func (f *Fenix) Steps(n int, dsn string) error

func (*Fenix) TakeScreenShot

func (f *Fenix) TakeScreenShot(pageURL, testName string, w, h float64)

func (*Fenix) UploadFile

func (f *Fenix) UploadFile(r *http.Request, destination, field string, fs filesystems.FS) error

func (*Fenix) Validator

func (f *Fenix) Validator(data url.Values) *Validation

func (*Fenix) WriteJSON

func (f *Fenix) WriteJSON(w http.ResponseWriter, status int, data interface{}, headers ...http.Header) error

Write JSON file

func (*Fenix) WriteXML

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

Write XML file

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, msg string)

func (*Validation) Check

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

func (*Validation) Has

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

func (*Validation) IsDateISO

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

func (*Validation) IsDateMMDDYYYY

func (v *Validation) IsDateMMDDYYYY(field, val string)

func (*Validation) IsEmail

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

func (*Validation) IsFloat

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

func (*Validation) IsInt

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

func (*Validation) NoSpaces

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

func (*Validation) Required

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

func (*Validation) Valid

func (v *Validation) Valid() bool

Directories

Path Synopsis
cmd
cli
package to send mail
package to send mail

Jump to

Keyboard shortcuts

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