Documentation
¶
Index ¶
- func Routes() http.Handler
- type Database
- type Encryption
- type Server
- type Skywalker
- func (c *Skywalker) BuildDSN() string
- func (c *Skywalker) CreateDirIfNotExist(path string) error
- func (c *Skywalker) CreateFileIfNotExist(path string) error
- func (s *Skywalker) DownloadFile(w http.ResponseWriter, r *http.Request, pathToFile, fileName string) error
- func (s *Skywalker) Error404(w http.ResponseWriter, r *http.Request)
- func (s *Skywalker) Error500(w http.ResponseWriter, r *http.Request)
- func (s *Skywalker) ErrorForbidden(w http.ResponseWriter, r *http.Request)
- func (s *Skywalker) ErrorStatus(w http.ResponseWriter, status int)
- func (s *Skywalker) ErrorUnauthorized(w http.ResponseWriter, r *http.Request)
- func (s *Skywalker) Init(p initPaths) error
- func (s *Skywalker) ListenAndServe()
- func (s *Skywalker) LoadTime(start time.Time)
- func (s *Skywalker) MigrateDownAll(dsn string) error
- func (s *Skywalker) MigrateForce(dsn string) error
- func (s *Skywalker) MigrateUp(dsn string) error
- func (s *Skywalker) New(rootPath string) error
- func (s *Skywalker) NoSurf(next http.Handler) http.Handler
- func (s *Skywalker) OpenDB(dbType, dsn string) (*sql.DB, error)
- func (c *Skywalker) RandomString(n int) string
- func (s *Skywalker) ReadJSON(w http.ResponseWriter, r *http.Request, data interface{}) error
- func (s *Skywalker) SessionLoad(next http.Handler) http.Handler
- func (s *Skywalker) Steps(n int, dsn string) error
- func (s *Skywalker) Validator(data url.Values) *Validation
- func (s *Skywalker) WriteJSON(w http.ResponseWriter, status int, data interface{}, headers ...http.Header) error
- func (s *Skywalker) WriteXML(w http.ResponseWriter, status int, data interface{}, headers ...http.Header) error
- 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 ¶
Types ¶
type Encryption ¶
type Encryption struct {
Key []byte
}
Encryption encrypts and decrypts strings using AES-GCM with the supplied Key (16, 24, or 32 bytes for AES-128/192/256).
type Skywalker ¶
type Skywalker struct {
AppName string
Debug bool
Version string
// Log is the structured logger for the application. InfoLog and ErrorLog
// are compatibility bridges that emit through the same handler.
Log *slog.Logger
ErrorLog *log.Logger
InfoLog *log.Logger
RootPath string
Routes *chi.Mux
Render *render.Render // render is a pointer to the render package
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{}
// contains filtered or unexported fields
}
Skywalker is the overall type for the Skywalker package. Members that are exported in this type are are available to any application that uses it
func (*Skywalker) CreateDirIfNotExist ¶
CreateDirIf NotExsit creates a new directory if it doesn't exist.
func (*Skywalker) CreateFileIfNotExist ¶
CreateFileIfNotExist creates a new file at path if it does not exist.
func (*Skywalker) DownloadFile ¶
func (s *Skywalker) DownloadFile(w http.ResponseWriter, r *http.Request, pathToFile, fileName string) error
DownloadFile downloads a file
func (*Skywalker) Error404 ¶
func (s *Skywalker) Error404(w http.ResponseWriter, r *http.Request)
Error404 returns page not found response
func (*Skywalker) Error500 ¶
func (s *Skywalker) Error500(w http.ResponseWriter, r *http.Request)
Error500 returns internal server error response
func (*Skywalker) ErrorForbidden ¶
func (s *Skywalker) ErrorForbidden(w http.ResponseWriter, r *http.Request)
ErrorForbidden returns a forbidden status message (client is known)
func (*Skywalker) ErrorStatus ¶
func (s *Skywalker) ErrorStatus(w http.ResponseWriter, status int)
ErrorStatus returns a response with the supplied http status
func (*Skywalker) ErrorUnauthorized ¶
func (s *Skywalker) ErrorUnauthorized(w http.ResponseWriter, r *http.Request)
ErrorUnauthorized sends an unauthorized status (client is not known)
func (*Skywalker) ListenAndServe ¶
func (s *Skywalker) ListenAndServe()
ListenAndServe starts the web server. WriteTimeout is 30s to match ReadTimeout: a single request/response cycle should never take minutes, and a short write timeout stops slow or stalled clients from pinning handler goroutines. IdleTimeout is 120s so idle keep-alive connections outlive the per-request timeouts and can be reused across many requests.
func (*Skywalker) LoadTime ¶
LoadTime calculates function execution time. To use, add defer c.LoadTime(time.Now()) to the function body
func (*Skywalker) MigrateDownAll ¶
func (*Skywalker) MigrateForce ¶
func (*Skywalker) New ¶
New reads the .env file, creates our application config, populates the Skywalker type with settings based on .env values, and creates necessary folders and files if they don't exist
func (*Skywalker) RandomString ¶
RandomString generates a random string of length n from values in the const randomString, drawing each character uniformly via crypto/rand.
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
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
cli
command
|
|
|
Package urlsigner signs URLs with an embedded timestamp and an HMAC-SHA256 signature, so links such as password-reset URLs can be verified and expired without any server-side state.
|
Package urlsigner signs URLs with an embedded timestamp and an HMAC-SHA256 signature, so links such as password-reset URLs can be verified and expired without any server-side state. |