func MarshalProtobuf(results []*MetricData) ([]byte, error) { response := pb.MultiFetchResponse{} for _, metric := range results { response.Metrics = append(response.Metrics, &((*metric).FetchResponse)) } b, err := response.Marshal() if err != nil { return nil, err } return b, nil }
func marshalProtobuf(results []*metricData) []byte { response := pb.MultiFetchResponse{} for _, metric := range results { response.Metrics = append(response.Metrics, &((*metric).FetchResponse)) } b, err := response.Marshal() if err != nil { logger.Logf("proto.Marshal: %v", err) } return b }
func returnRender(w http.ResponseWriter, format string, metrics pb.MultiFetchResponse) { switch format { case "protobuf": w.Header().Set("Content-Type", "application/protobuf") b, _ := metrics.Marshal() w.Write(b) case "json": presponse := createRenderResponse(metrics, nil) w.Header().Set("Content-Type", "application/json") e := json.NewEncoder(w) e.Encode(presponse) case "", "pickle": presponse := createRenderResponse(metrics, pickle.None{}) w.Header().Set("Content-Type", "application/pickle") e := pickle.NewEncoder(w) e.Encode(presponse) } }