Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Config appConfig
var Version = "1.0"
Version specifies the current version of the application. The value of this variable is replaced with the latest git tag by "make" while building or running the application.
Functions ¶
func Init ¶
Init returns a middleware that prepares the request context and processing environment. The middleware will populate RequestContext, handle possible panics and errors from the processing handlers, and add an access log entry.
func LoadConfig ¶
func Transactional ¶
func Transactional(db *dbx.DB) routing.Handler
Transactional returns a handler that encloses the nested handlers with a DB transaction. If a nested handler returns an error or a panic happens, it will rollback the transaction. Otherwise it will commit the transaction after the nested handlers finish execution. By calling app.Context.SetRollback(true), you may also explicitly request to rollback the transaction.
Types ¶
type Logger ¶
type Logger interface { Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Warnf(format string, args ...interface{}) Errorf(format string, args ...interface{}) Debug(args ...interface{}) Info(args ...interface{}) Warn(args ...interface{}) Error(args ...interface{}) }
Logger defines the logger interface that is exposed via RequestScope.
type RequestScope ¶
type RequestScope interface { Logger // UserID returns the ID of the user for the current request UserID() string // Tx returns the currently active database transaction that can be used for DB query purpose Tx() *dbx.Tx // SetTx sets the database transaction SetTx(tx *dbx.Tx) // Rollback returns a value indicating whether the current database transaction should be rolled back Rollback() bool // SetRollback sets a value indicating whether the current database transaction should be rolled back SetRollback(bool) // Now returns the timestamp representing the time when the request is being processed Now() time.Time }
RequestScope contains the application-specific information that are carried around in a request.
func GetRequestScope ¶
func GetRequestScope(c *routing.Context) RequestScope
GetRequestScope returns the RequestScope of the current request.