mirror of
https://github.com/datarhei/core.git
synced 2025-11-02 20:24:02 +08:00
Allow to add self to nodes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
@@ -50,6 +51,21 @@ func (v MetricsResponseValue) MarshalJSON() ([]byte, error) {
|
||||
return []byte(s), nil
|
||||
}
|
||||
|
||||
// MarshalJSON unmarshals a JSON to MetricsResponseValue
|
||||
func (v *MetricsResponseValue) UnmarshalJSON(data []byte) error {
|
||||
x := []float64{}
|
||||
|
||||
err := json.Unmarshal(data, &x)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
v.TS = time.Unix(int64(x[0]), 0)
|
||||
v.Value = x[1]
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type MetricsResponse struct {
|
||||
Timerange int64 `json:"timerange_sec" format:"int64"`
|
||||
Interval int64 `json:"interval_sec" format:"int64"`
|
||||
|
||||
Reference in New Issue
Block a user