Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Config appConfig
Config stores the application-wide configurations
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 ¶
LoadConfig loads configuration from the given list of paths and populates it into the Config variable. The configuration file(s) should be named as app.yaml. Environment variables with the prefix "RESTFUL_" in their names are also read automatically.
Types ¶
type Logger ¶
type Logger interface { // adds a field that should be added to every message being logged SetField(name, value string) 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 // SetUserID sets the ID of the currently authenticated user SetUserID(id string) // RequestID returns the ID of the current request RequestID() 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) // 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.