do not hardcode influx token
This commit is contained in:
parent
867ae88bd3
commit
6edda45abf
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -32,6 +33,9 @@ type OneMetric struct {
|
||||||
DaysUntilDeactivated int // berechneter Wert
|
DaysUntilDeactivated int // berechneter Wert
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// global variables
|
||||||
|
var INFLUX_RO_TOKEN = os.Getenv("INFLUX_RO_TOKEN")
|
||||||
|
|
||||||
// metrics handler
|
// metrics handler
|
||||||
|
|
||||||
func string2float64(s string) float64 {
|
func string2float64(s string) float64 {
|
||||||
|
|
@ -117,7 +121,7 @@ func metricsHandler(response http.ResponseWriter, request *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set headers
|
// Set headers
|
||||||
req.Header.Set("Authorization", "Token TQvQxxLLAj1kTKWuEqcx7BA-KfE6WtJUeDlPa_Dnvms6Zqf6uh6lMbpXtzcsCjKO_x3PrpxxGDR5E6YnDB5PFg==")
|
req.Header.Set("Authorization", "Token "+INFLUX_RO_TOKEN)
|
||||||
req.Header.Set("accept", "application/csv")
|
req.Header.Set("accept", "application/csv")
|
||||||
req.Header.Set("content-type", "application/vnd.flux")
|
req.Header.Set("content-type", "application/vnd.flux")
|
||||||
|
|
||||||
|
|
@ -275,7 +279,7 @@ func getLastMetrics(deveui string) OneMetric {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set headers
|
// Set headers
|
||||||
req.Header.Set("Authorization", "Token TQvQxxLLAj1kTKWuEqcx7BA-KfE6WtJUeDlPa_Dnvms6Zqf6uh6lMbpXtzcsCjKO_x3PrpxxGDR5E6YnDB5PFg==")
|
req.Header.Set("Authorization", "Token "+INFLUX_RO_TOKEN)
|
||||||
req.Header.Set("accept", "application/csv")
|
req.Header.Set("accept", "application/csv")
|
||||||
req.Header.Set("content-type", "application/vnd.flux")
|
req.Header.Set("content-type", "application/vnd.flux")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue