-
Notifications
You must be signed in to change notification settings - Fork 153
/
dialect.go
41 lines (33 loc) · 910 Bytes
/
dialect.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
package csv
import (
"net/http"
"github.com/influxdata/flux"
)
const DialectType = "csv"
// AddDialectMappings adds the influxql specific dialect mappings.
func AddDialectMappings(mappings flux.DialectMappings) error {
return mappings.Add(DialectType, func() flux.Dialect {
return &Dialect{
ResultEncoderConfig: DefaultEncoderConfig(),
}
})
}
// Dialect describes the output format of queries in CSV.
type Dialect struct {
ResultEncoderConfig
}
func (d Dialect) SetHeaders(w http.ResponseWriter) {
w.Header().Set("Content-Type", "text/csv; charset=utf-8")
w.Header().Set("Transfer-Encoding", "chunked")
}
func (d Dialect) Encoder() flux.MultiResultEncoder {
return NewMultiResultEncoder(d.ResultEncoderConfig)
}
func (d Dialect) DialectType() flux.DialectType {
return DialectType
}
func DefaultDialect() *Dialect {
return &Dialect{
ResultEncoderConfig: DefaultEncoderConfig(),
}
}