-
Notifications
You must be signed in to change notification settings - Fork 3
/
value.go
40 lines (31 loc) · 790 Bytes
/
value.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
package formstream
// Value first value of the key.
func (p *Parser) Value(key string) (string, Header, bool) {
value := p.valueMap[key]
if len(value) == 0 {
return "", Header{}, false
}
content, header := value[0].Unwrap()
return content, header, true
}
// ValueRaw first value of the key.
func (p *Parser) ValueRaw(key string) ([]byte, Header, bool) {
value := p.valueMap[key]
if len(value) == 0 {
return nil, Header{}, false
}
content, header := value[0].UnwrapRaw()
return content, header, true
}
// Values all values of the key.
func (p *Parser) Values(key string) ([]Value, bool) {
value, ok := p.valueMap[key]
if !ok {
return nil, false
}
return value, true
}
// ValueMap all values.
func (p *Parser) ValueMap() map[string][]Value {
return p.valueMap
}