diff --git a/example-cfg.yml b/example-cfg.yml index e45768d..df5232f 100644 --- a/example-cfg.yml +++ b/example-cfg.yml @@ -4,6 +4,8 @@ clients: write_metrics: - irradiance - temperature + read_metrics: + - weather.* auth: type: sha256 hash: ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb # a @@ -32,16 +34,9 @@ clients: auth: # ... - # Anonymous login - - name: public_consumer - read_metrics: - - weather.* - auth: - type: anonymous - config: opentsdb: - url: http://opentsdb/api/ + url: http://192.168.30.2/api/ server: port: 8080 diff --git a/src/main.rs b/src/main.rs index ff50c03..f263bd0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,33 +16,38 @@ struct ClientData { } #[derive(Debug, Deserialize)] -struct QSParams { +struct QPutParams { + token: String, +} + +#[derive(Debug, Deserialize, Serialize)] +struct OtsdbPutData { + metric: String, + value: StringIntFloat, + timestamp: i64, + tags: HashMap, +} + +#[derive(Debug, Deserialize)] +struct QQueryParams { token: String, } #[derive(Debug, Deserialize, Serialize)] #[serde(untagged)] -enum OtsdbValue { +enum StringIntFloat { String(String), Integer(i64), Float(f64), } -#[derive(Debug, Deserialize, Serialize)] -struct OtsdbData { - metric: String, - value: OtsdbValue, - timestamp: i64, - tags: HashMap, -} - const CONFIG_FILE: &str = "config.yaml"; #[actix_web::post("/put")] async fn put_post( shared: web::Data, - qs: web::Query, - body: web::Json, + qs: web::Query, + body: web::Json, ) -> impl Responder { let authenticated_client = config::try_authenticate_client(&shared.cfg.clients, &qs.token);