Skip to content

Commit

Permalink
make: json response wip
Browse files Browse the repository at this point in the history
Took 20 minutes
  • Loading branch information
Nasfame committed Aug 30, 2024
1 parent 1b0d05b commit 6371452
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/bin/rocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,23 @@ async fn get_latest_release(client: &State<Client>, repo: &str) -> Result<Value,
let url = format!("https://api.github.com/repos/{repo}/releases/latest");
let response = client.get(&url).send().await?;
let github_release = response.json::<Value>().await?;
Ok(github_release)
// Ok(github_release)
make_json_response(&github_release).ok_or(json!({})).or_else(|e| Ok(e))
}

const REPO_GOLANG_AIR: &str = "air-verse/air";


fn make_json_response(github_release:&Value) ->Option<Value>{
let mut response = json!({
"version": github_release["tag_name"].as_str()?,
"notes": github_release["body"].as_str()?, //TODO: suffix
"pub_date": github_release["published_at"].as_str()?,
"platforms": {},
});
Some(response)
}

#[get("/<platform>/<version>?<msg>")]
async fn releases(
platform: &str,
Expand Down

0 comments on commit 6371452

Please sign in to comment.