Example #1
0
func (a *Handler) contextMaker(r *http.Request) (context.Context, error) {
	env, err := a.EnvParser.FromRequest(a.ctx, r)
	if err != nil {
		return a.ctx, err
	}
	return rellenv.WithEnv(a.ctx, env), nil
}
Example #2
0
File: web.go Project: stoyan/rell
func (a *Handler) contextMaker(r *http.Request) (context.Context, error) {
	env, err := a.EnvParser.FromRequest(a.ctx, r)
	if err != nil {
		return a.ctx, err
	}
	ctx := a.ctx
	ctx = rellenv.WithEnv(a.ctx, env)
	ctx = static.NewContext(ctx, a.Static)
	return ctx, nil
}
Example #3
0
func fromValues(t *testing.T, values url.Values) (*rellenv.Env, context.Context) {
	req, err := http.NewRequest(
		"GET",
		"http://www.fbrell.com/?"+values.Encode(),
		nil)
	if err != nil {
		t.Fatalf("Failed to create request: %s", err)
	}
	env, err := defaultParser().FromRequest(context.Background(), req)
	if err != nil {
		t.Fatalf("Failed to create env: %s", err)
	}
	return env, rellenv.WithEnv(context.Background(), env)
}
Example #4
0
File: web.go Project: daaku/rell
func (a *Handler) contextChanger(r *http.Request) (*http.Request, error) {
	env, err := a.EnvParser.FromRequest(r)
	if err != nil {
		return nil, err
	}

	ctx := r.Context()
	ctx = ctxerr.WithConfig(ctx, ctxerr.Config{
		StackMode:  ctxerr.StackModeMultiStack,
		StringMode: ctxerr.StringModeNone,
	})
	ctx = rellenv.WithEnv(ctx, env)
	ctx = static.NewContext(ctx, a.Static)
	return r.WithContext(ctx), nil
}