forked from vaniila/hyper
/
context.go
64 lines (55 loc) · 3.28 KB
/
context.go
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package server
import (
"context"
"net/http"
"time"
opentracing "github.com/opentracing/opentracing-go"
"github.com/vaniila/hyper/router"
)
// ERRORS GraphQL error reference
const ERRORS = "graphql-errors"
// graphql context
type ctx struct {
private router.Context
}
func (v *ctx) Deadline() (time.Time, bool) { return v.private.Deadline() }
func (v *ctx) Done() <-chan struct{} { return v.private.Done() }
func (v *ctx) Err() error { return v.private.Err() }
func (v *ctx) Value(key interface{}) interface{} { return v.private.Value(key) }
func (v *ctx) Identity() router.Identity { return v.private.Identity() }
func (v *ctx) MachineID() string { return v.private.MachineID() }
func (v *ctx) ProcessID() string { return v.private.ProcessID() }
func (v *ctx) Context() context.Context { return v.private.Context() }
func (v *ctx) Req() *http.Request { return v.private.Req() }
func (v *ctx) Res() http.ResponseWriter { return v.private.Res() }
func (v *ctx) Client() router.Client { return v.private.Client() }
func (v *ctx) Cache() router.CacheAdaptor { return v.private.Cache() }
func (v *ctx) Message() router.MessageAdaptor { return v.private.Message() }
func (v *ctx) GQLSubscription() router.GQLSubscriptionAdaptor { return v.private.GQLSubscription() }
func (v *ctx) DataLoader(o interface{}) router.DataLoaderAdaptor { return v.private.DataLoader(o) }
func (v *ctx) KV() router.KV { return v.private.KV() }
func (v *ctx) Cookie() router.Cookie { return v.private.Cookie() }
func (v *ctx) Header() router.Header { return v.private.Header() }
func (v *ctx) MustParam(s string) router.Value { return v.private.MustParam(s) }
func (v *ctx) MustQuery(s string) router.Value { return v.private.MustQuery(s) }
func (v *ctx) MustBody(s string) router.Value { return v.private.MustBody(s) }
func (v *ctx) Param(s string) (router.Value, error) { return v.private.Param(s) }
func (v *ctx) Query(s string) (router.Value, error) { return v.private.Query(s) }
func (v *ctx) Body(s string) (router.Value, error) { return v.private.Body(s) }
func (v *ctx) File(s string) []byte { return v.private.File(s) }
func (v *ctx) Tracer() opentracing.Tracer { return v.private.Tracer() }
func (v *ctx) Abort() { v.private.Abort() }
func (v *ctx) IsAborted() bool { return v.private.IsAborted() }
func (v *ctx) Native() router.Context { return v.private }
func (v *ctx) StartSpan(s string, opts ...opentracing.StartSpanOption) opentracing.Span {
return v.private.StartSpan(s, opts...)
}
func (v *ctx) HasErrors() bool {
o := v.private.KV().Get(ERRORS)
return o != nil && len(o) > 0
}
func (v *ctx) Errors() []error {
return nil
}
func (v *ctx) GraphQLError(e error) {
}