Ejemplo n.º 1
0
func TestContextMustReader(t *testing.T) {
	mr := config.NewMockReader()
	ctx := config.NewContextReader(context.Background(), mr)
	mrHave := config.FromContextReader(ctx)
	assert.Exactly(t, mr, mrHave)

	ctx = config.NewContextReader(context.Background(), nil)
	mrHave = config.FromContextReader(ctx)
	assert.Exactly(t, config.DefaultManager, mrHave)
}
Ejemplo n.º 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.FromContextReader(ctx), r)
}