mirror of
https://github.com/shiroyashik/sculptor.git
synced 2025-12-06 13:01:12 +03:00
Начало положено...
This commit is contained in:
commit
3fd49300db
12 changed files with 2361 additions and 0 deletions
14
elyby-api/Cargo.toml
Normal file
14
elyby-api/Cargo.toml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
[package]
|
||||
name = "elyby-api"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.83"
|
||||
log = "0.4.21"
|
||||
reqwest = "0.12.4"
|
||||
serde = { version = "1.0.201", features = ["derive"] }
|
||||
serde_json = "1.0.117"
|
||||
tokio = { version = "1.37.0", features = ["full"] }
|
||||
31
elyby-api/src/lib.rs
Normal file
31
elyby-api/src/lib.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
use anyhow::{anyhow, Result};
|
||||
use log::debug;
|
||||
|
||||
pub async fn has_joined(server_id: &str, username: &str) -> Result<bool> {
|
||||
let client = reqwest::Client::new();
|
||||
let res = client.get(
|
||||
format!("http://minecraft.ely.by/session/hasJoined?serverId={server_id}&username={username}")).send().await?;
|
||||
debug!("{res:?}");
|
||||
match res.status().as_u16() {
|
||||
200 => Ok(true),
|
||||
401 => Ok(false),
|
||||
_ => Err(anyhow!("Unknown code: {}", res.status().as_u16()))
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_has_joined() {
|
||||
let result = has_joined("0f8fef917f1f62b963804d822b67fe6f59aad7d", "test").await.unwrap();
|
||||
assert_eq!(result, false)
|
||||
}
|
||||
|
||||
// #[cfg(test)]
|
||||
// mod tests {
|
||||
// use super::*;
|
||||
|
||||
// #[test]
|
||||
// fn it_works() {
|
||||
// let result = add(2, 2);
|
||||
// assert_eq!(result, 4);
|
||||
// }
|
||||
// }
|
||||
Loading…
Add table
Add a link
Reference in a new issue