cloud_terrastodon_credentials 0.35.1

Helpers for getting Azure PAT and stuff for Cloud Terrastodon
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use serde::Deserialize;
use serde::Serialize;
use serde_json::Value;

#[derive(Debug, Serialize, Deserialize, PartialEq)]
#[serde(untagged)]
pub enum RestResponseBody {
    Json(Value),
    Text(String),
}

pub fn parse_response_body(content: String) -> RestResponseBody {
    match serde_json::from_str::<Value>(&content) {
        Ok(value) => RestResponseBody::Json(value),
        Err(_) => RestResponseBody::Text(content),
    }
}