Documentation
¶
Index ¶
- type Common
- func (c *Common) BuildDSN() string
- func (c *Common) CreateDirIfNotExist(path string) error
- func (c *Common) CreateFileIfNotExists(path string) error
- func (c *Common) DownloadFile(w http.ResponseWriter, r *http.Request, pathToFile, fileName string) error
- func (c *Common) Error404(w http.ResponseWriter, r *http.Request)
- func (c *Common) Error500(w http.ResponseWriter, r *http.Request)
- func (c *Common) ErrorForbidden(w http.ResponseWriter, r *http.Request)
- func (c *Common) ErrorStatus(w http.ResponseWriter, status int)
- func (c *Common) ErrorUnauthorized(w http.ResponseWriter, r *http.Request)
- func (c *Common) ListenAndServe()
- func (c *Common) LoadTime(start time.Time)
- func (c *Common) New(rootPath string) error
- func (c *Common) OpenDB(dbType, dsn string) (*sql.DB, error)
- func (c *Common) RandomString(n int) string
- func (c *Common) ReadJSON(w http.ResponseWriter, r *http.Request, data interface{}) error
- func (c *Common) WriteJSON(w http.ResponseWriter, status int, data interface{}, headers ...http.Header) error
- type Database
- type DatabaseConfig
- type Encryption
- type JsonApiResponse
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Common ¶
type Common struct {
AppName string
Debug bool
Version string
RootPath string
Routes *chi.Mux
DB *gorm.DB
S3 *session.Session
EncryptionKey string
Cache cache.Cache
Server Server
// contains filtered or unexported fields
}
func (*Common) BuildDSN ¶
BuildDSN builds the datasource name for our database, and returns it as a string
func (*Common) CreateDirIfNotExist ¶
CreateDirIfNotExist creates a new directory if it does not exist
func (*Common) CreateFileIfNotExists ¶
CreateFileIfNotExists creates a new file at path if it does not exist
func (*Common) DownloadFile ¶
func (c *Common) DownloadFile(w http.ResponseWriter, r *http.Request, pathToFile, fileName string) error
DownloadFile downloads a file
func (*Common) Error404 ¶
func (c *Common) Error404(w http.ResponseWriter, r *http.Request)
Error404 returns page not found response
func (*Common) Error500 ¶
func (c *Common) Error500(w http.ResponseWriter, r *http.Request)
Error500 returns internal server error response
func (*Common) ErrorForbidden ¶
func (c *Common) ErrorForbidden(w http.ResponseWriter, r *http.Request)
ErrorForbidden returns a forbidden status message (client is known)
func (*Common) ErrorStatus ¶
func (c *Common) ErrorStatus(w http.ResponseWriter, status int)
ErrorStatus returns a response with the supplied http status
func (*Common) ErrorUnauthorized ¶
func (c *Common) ErrorUnauthorized(w http.ResponseWriter, r *http.Request)
ErrorUnauthorized sends an unauthorized status (client is not known)
func (*Common) ListenAndServe ¶
func (c *Common) ListenAndServe()
ListenAndServe starts the web server
func (*Common) RandomString ¶
RandomString generates a random string length n from values in the const randomString
type DatabaseConfig ¶
type DatabaseConfig struct {
// contains filtered or unexported fields
}
func (*DatabaseConfig) BuildDSN ¶
func (d *DatabaseConfig) BuildDSN() string
func (*DatabaseConfig) OpenDbConn ¶
func (d *DatabaseConfig) OpenDbConn() (db.Session, error)
type Encryption ¶
type Encryption struct {
Key []byte
}