-
Notifications
You must be signed in to change notification settings - Fork 0
/
ctx.go
67 lines (56 loc) · 1.79 KB
/
ctx.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
65
66
67
package inreq
import "github.com/rrgmc/instruct"
// DecodeContext is the context sent to DecodeOperation.
type DecodeContext interface {
instruct.DecodeContext
// PathValue is the function used to extract the path from the request.
PathValue() PathValue
// BodyDecoder is the interface used to parse body data into structs.
BodyDecoder() BodyDecoder
// IsBodyDecoded returns whether the body was already decoded.
IsBodyDecoded() bool
// DecodedBody signals that the body was decoded.
DecodedBody()
// SliceSplitSeparator returns the string used for string-to-array conversions. The default is ",".
SliceSplitSeparator() string
// AllowReadBody returns whether the user gave permission to read the request body.
AllowReadBody() bool
// EnsureAllQueryUsed returns whether to check if all query parameters were used.
EnsureAllQueryUsed() bool
// EnsureAllFormUsed returns whether to check if all form parameters were used.
EnsureAllFormUsed() bool
}
type decodeContext struct {
instruct.DefaultDecodeContext
pathValue PathValue
bodyDecoder BodyDecoder
decodedBody bool
allowReadBody bool
sliceSplitSeparator string
ensureAllQueryUsed bool
ensureAllFormUsed bool
}
func (d *decodeContext) PathValue() PathValue {
return d.pathValue
}
func (d *decodeContext) BodyDecoder() BodyDecoder {
return d.bodyDecoder
}
func (d *decodeContext) IsBodyDecoded() bool {
return d.decodedBody
}
func (d *decodeContext) DecodedBody() {
d.decodedBody = true
}
func (d *decodeContext) AllowReadBody() bool {
return d.allowReadBody
}
func (d *decodeContext) SliceSplitSeparator() string {
return d.sliceSplitSeparator
}
func (d *decodeContext) EnsureAllQueryUsed() bool {
return d.ensureAllQueryUsed
}
func (d *decodeContext) EnsureAllFormUsed() bool {
return d.ensureAllFormUsed
}