コード例 #1
0
ファイル: token.go プロジェクト: devick/flynn
// retrieveToken takes a *Config and uses that to retrieve an *internal.Token.
// This token is then mapped from *internal.Token into an *oauth2.Token which is returned along
// with an error..
func retrieveToken(ctx context.Context, c *Config, v url.Values) (*Token, error) {
	tk, err := internal.RetrieveToken(ctx, c.ClientID, c.ClientSecret, c.Endpoint.TokenURL, v)
	if err != nil {
		return nil, err
	}
	token := tokenFromInternal(tk)
	if notifierFunc, ok := ctx.Value(TokenRefreshNotifier).(TokenRefreshNotifierFunc); ok {
		notifierFunc(token)
	}
	return token, nil
}
コード例 #2
0
ファイル: transport.go プロジェクト: devick/flynn
func ContextClient(ctx context.Context) (*http.Client, error) {
	for _, fn := range contextClientFuncs {
		c, err := fn(ctx)
		if err != nil {
			return nil, err
		}
		if c != nil {
			return c, nil
		}
	}
	if hc, ok := ctx.Value(HTTPClient).(*http.Client); ok {
		return hc, nil
	}
	return http.DefaultClient, nil
}
コード例 #3
0
ファイル: controller.go プロジェクト: GrimDerp/flynn
func (c *controllerAPI) getApp(ctx context.Context) *ct.App {
	return ctx.Value("app").(*ct.App)
}
コード例 #4
0
ファイル: api.go プロジェクト: eldarion-gondor/cli
func (api *API) SessionFromContext(ctx context.Context) *sessions.Session {
	return ctx.Value(ctxSessionKey).(*sessions.Session)
}
コード例 #5
0
ファイル: ctxhelper.go プロジェクト: devick/flynn
// StartTimeFromContext extracts a start time from a context.
func StartTimeFromContext(ctx context.Context) (start time.Time, ok bool) {
	start, ok = ctx.Value(ctxKeyStartTime).(time.Time)
	return
}
コード例 #6
0
ファイル: ctxhelper.go プロジェクト: devick/flynn
// RequestIDFromContext extracts a request ID from a context.
func RequestIDFromContext(ctx context.Context) (id string, ok bool) {
	id, ok = ctx.Value(ctxKeyReqID).(string)
	return
}
コード例 #7
0
ファイル: ctxhelper.go プロジェクト: devick/flynn
// ParamsFromContext extracts params from a context.
func ParamsFromContext(ctx context.Context) (params httprouter.Params, ok bool) {
	params, ok = ctx.Value(ctxKeyParams).(httprouter.Params)
	return
}
コード例 #8
0
ファイル: ctxhelper.go プロジェクト: devick/flynn
// LoggerFromContext extracts a logger from a context.
func LoggerFromContext(ctx context.Context) (logger log.Logger, ok bool) {
	logger, ok = ctx.Value(ctxKeyLogger).(log.Logger)
	return
}
コード例 #9
0
ファイル: ctxhelper.go プロジェクト: devick/flynn
// ComponentNameFromContext extracts a component name from a context.
func ComponentNameFromContext(ctx context.Context) (componentName string, ok bool) {
	componentName, ok = ctx.Value(ctxKeyComponent).(string)
	return
}