hotfix #186
@ -42,10 +42,10 @@ type Handler struct {
|
||||
type Option func(*Options)
|
||||
|
||||
type Options struct {
|
||||
Meter meter.Meter
|
||||
Name string
|
||||
MeterOptions []options.Option
|
||||
Gzip bool
|
||||
Meter meter.Meter
|
||||
Name string
|
||||
MeterOptions []options.Option
|
||||
DisableCompress bool
|
||||
}
|
||||
|
||||
func Meter(m meter.Meter) Option {
|
||||
@ -60,9 +60,9 @@ func Name(name string) Option {
|
||||
}
|
||||
}
|
||||
|
||||
func Gzip(g bool) Option {
|
||||
func DisableCompress(g bool) Option {
|
||||
return func(o *Options) {
|
||||
o.Gzip = g
|
||||
o.DisableCompress = g
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ func MeterOptions(opts ...options.Option) Option {
|
||||
}
|
||||
|
||||
func NewOptions(opts ...Option) Options {
|
||||
options := Options{Meter: meter.DefaultMeter, Gzip: true}
|
||||
options := Options{Meter: meter.DefaultMeter, DisableCompress: false}
|
||||
for _, o := range opts {
|
||||
o(&options)
|
||||
}
|
||||
@ -97,7 +97,7 @@ func (h *Handler) Metrics(ctx context.Context, req *codecpb.Frame, rsp *codecpb.
|
||||
|
||||
w := io.Writer(buf)
|
||||
|
||||
if md, ok := metadata.FromIncomingContext(ctx); gzipAccepted(md) && ok && h.opts.Gzip {
|
||||
if md, ok := metadata.FromIncomingContext(ctx); gzipAccepted(md) && ok && !h.opts.DisableCompress {
|
||||
omd, _ := metadata.FromOutgoingContext(ctx)
|
||||
omd.Set(contentEncodingHeader, "gzip")
|
||||
gz := gzipPool.Get().(*gzip.Writer)
|
||||
|
Loading…
Reference in New Issue
Block a user