Example #1
0
File: client.go Project: logan/heim
func (c *Client) FromRequest(ctx scope.Context, r *http.Request) {
	c.UserAgent = r.Header.Get("User-Agent")
	c.Connected = time.Now()
	c.IP = getIP(r)

	var k clientKey
	ctx.Set(k, c)
}
Example #2
0
func SetLogger(ctx scope.Context, logger *logrus.Logger) {
	ctx.Set(loggerKey, logger)
}
Example #3
0
func LoggingContext(ctx scope.Context, prefix string) scope.Context {
	logger := log.New(os.Stdout, prefix, logFlags)
	ctx.Set(logCtx, logger)
	return ctx
}
Example #4
0
func LoggingContext(ctx scope.Context, w io.Writer, prefix string) scope.Context {
	logger := log.New(w, prefix, logFlags)
	ctx.Set(logCtx, logger)
	return ctx
}