aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/Xe/ln/context.go
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2018-11-13 07:30:55 -0800
committerChristine Dodrill <me@christine.website>2018-11-13 07:30:55 -0800
commite245d89daa6dffc441be07dcb81b985397446378 (patch)
tree0d399b0de689f43fbbfaa979d939dca8aa03e716 /vendor/github.com/Xe/ln/context.go
parentbc8b7e5471e7f4984ee69af07d8e9632df01b85b (diff)
parent8fe5504c3a5e9cd8409d5296d128603a231567ac (diff)
downloadxesite-e245d89daa6dffc441be07dcb81b985397446378.tar.xz
xesite-e245d89daa6dffc441be07dcb81b985397446378.zip
Merge branch 'master' of git@github.com:Xe/site.git
Diffstat (limited to 'vendor/github.com/Xe/ln/context.go')
-rw-r--r--vendor/github.com/Xe/ln/context.go38
1 files changed, 0 insertions, 38 deletions
diff --git a/vendor/github.com/Xe/ln/context.go b/vendor/github.com/Xe/ln/context.go
deleted file mode 100644
index 0ea3229..0000000
--- a/vendor/github.com/Xe/ln/context.go
+++ /dev/null
@@ -1,38 +0,0 @@
-package ln
-
-import (
- "context"
-)
-
-type ctxKey int
-
-const (
- fKey = iota
-)
-
-// WithF stores or appends a given F instance into a context.
-func WithF(ctx context.Context, f F) context.Context {
- pf, ok := FFromContext(ctx)
- if !ok {
- return context.WithValue(ctx, fKey, f)
- }
-
- pf.Extend(f)
-
- return context.WithValue(ctx, fKey, pf)
-}
-
-// FFromContext fetches the `F` out of the context if it exists.
-func FFromContext(ctx context.Context) (F, bool) {
- fvp := ctx.Value(fKey)
- if fvp == nil {
- return nil, false
- }
-
- f, ok := fvp.(F)
- if !ok {
- return nil, false
- }
-
- return f, true
-}