示例#1
0
func TestContextMustGetter(t *testing.T) {
	mr := config.NewMockGetter()
	ctx := config.WithContextGetter(context.Background(), mr)
	mrHave := config.FromContextGetter(ctx)
	assert.Exactly(t, mr, mrHave)

	ctx = config.WithContextGetter(context.Background(), nil)
	mrHave = config.FromContextGetter(ctx)
	assert.Exactly(t, config.DefaultService, mrHave)
}
示例#2
0
// CtxIsSecure same as IsSecure() but extract the config.Reader out of the context.
// Wrapper function.
func CtxIsSecure(ctx context.Context, r *http.Request) bool {
	return IsSecure(config.FromContextGetter(ctx), r)
}