aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/gorilla/csrf/context_legacy.go
blob: f88c9ebcda9dcb3e0b6d2a7bc0daab85feb5131c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// +build !go1.7

package csrf

import (
	"net/http"

	"github.com/gorilla/context"

	"github.com/pkg/errors"
)

func contextGet(r *http.Request, key string) (interface{}, error) {
	if val, ok := context.GetOk(r, key); ok {
		return val, nil
	}

	return nil, errors.Errorf("no value exists in the context for key %q", key)
}

func contextSave(r *http.Request, key string, val interface{}) *http.Request {
	context.Set(r, key, val)
	return r
}

func contextClear(r *http.Request) {
	context.Clear(r)
}