Documentation ¶
Index ¶
- type Database
- type Encryption
- type Navitas
- func (n *Navitas) BuildDSN() 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
- func (n *Navitas) Error404(w http.ResponseWriter, r *http.Request)
- func (n *Navitas) Error500(w http.ResponseWriter, r *http.Request)
- func (n *Navitas) ErrorForbidden(w http.ResponseWriter, r *http.Request)
- func (n *Navitas) ErrorStatus(w http.ResponseWriter, status int)
- func (n *Navitas) ErrorUnauthorized(w http.ResponseWriter, r *http.Request)
- func (n *Navitas) FetchPage(pageURL string) *rod.Page
- func (n *Navitas) Init(p initPaths) error
- func (n *Navitas) ListenAndServe()
- func (n *Navitas) LoadTime(start time.Time)
- 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
- func (n *Navitas) NoSurf(next http.Handler) http.Handler
- func (n *Navitas) OpenDB(dbType, dsn string) (*sql.DB, error)
- func (n *Navitas) RandomString(val int) string
- 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
- func (n *Navitas) WriteXML(w http.ResponseWriter, status int, data interface{}, headers ...http.Header) error
- type RPCServer
- type Server
- type Validation
- func (v *Validation) AddError(key, message string)
- func (v *Validation) Check(ok bool, key, message string)
- func (v *Validation) Has(field string, r *http.Request) bool
- func (v *Validation) IsDateISO(field, value string)
- func (v *Validation) IsEmail(field, value string)
- func (v *Validation) IsFloat(field, value string)
- func (v *Validation) IsInt(field, value string)
- func (v *Validation) NoSpaces(field, value string)
- func (v *Validation) Required(r *http.Request, fields ...string)
- func (v *Validation) Valid() bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Encryption ¶
type Encryption struct {
Key []byte
}
type Navitas ¶
type Navitas struct { // 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 (*Navitas) BuildDSN ¶
BuildDSN builds the datasource name for our database, and returns it as a string
func (*Navitas) CreateDirIfNotExist ¶
func (*Navitas) CreateFileIfNotExists ¶
func (*Navitas) DownloadFile ¶
func (n *Navitas) DownloadFile(w http.ResponseWriter, r *http.Request, pathToFile, fileName string) error
DownloadFile downloads a file
func (*Navitas) Error404 ¶
func (n *Navitas) Error404(w http.ResponseWriter, r *http.Request)
Error404 returns page not found response
func (*Navitas) Error500 ¶
func (n *Navitas) Error500(w http.ResponseWriter, r *http.Request)
Error500 returns internal server error response
func (*Navitas) ErrorForbidden ¶
func (n *Navitas) ErrorForbidden(w http.ResponseWriter, r *http.Request)
ErrorForbidden returns a forbidden status message (client is known)
func (*Navitas) ErrorStatus ¶
func (n *Navitas) ErrorStatus(w http.ResponseWriter, status int)
ErrorStatus returns a response with the supplied http status
func (*Navitas) ErrorUnauthorized ¶
func (n *Navitas) ErrorUnauthorized(w http.ResponseWriter, r *http.Request)
ErrorUnauthorized sends an unauthorized status (client is not known)
func (*Navitas) ListenAndServe ¶
func (n *Navitas) ListenAndServe()
ListenAndServe starts the web server
func (*Navitas) LoadTime ¶
LoadTime calculates function execution time. To use, add defer c.LoadTime(time.Now()) to the function body
func (*Navitas) MigrateDownAll ¶
func (*Navitas) MigrateForce ¶
func (*Navitas) New ¶
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 (*Navitas) OpenDB ¶
OpenDB opens a connection to a sql database. dbType must be one of postgres (or pgx). TODO: add support for mysql/mariadb
func (*Navitas) RandomString ¶
RandomString generates a random string length n from values in the const randomString
func (*Navitas) SelectElementByID ¶
func (*Navitas) TakeScreenShot ¶
func (*Navitas) UploadFile ¶
type Validation ¶
func (*Validation) AddError ¶
func (v *Validation) AddError(key, message string)
func (*Validation) Check ¶
func (v *Validation) Check(ok bool, key, message string)
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) Valid ¶
func (v *Validation) Valid() bool