feat(reqwest): now uses more idiomatic way of sending a json

This commit is contained in:
darkicewolf50 2025-05-06 12:35:18 -06:00
parent 52ae1bb1e2
commit 9d678776a5
2 changed files with 5 additions and 4 deletions

View File

@ -8,7 +8,7 @@ actix-web = "4"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_json = "1" serde_json = "1"
yaml-rust2 = "0.10.1" yaml-rust2 = "0.10.1"
reqwest = "0.12.15" reqwest = { version = "0.12.15", features = ["json"] }
[profile.release] [profile.release]
debug = false debug = false

View File

@ -114,6 +114,7 @@ pub async fn project(limit: web::Path<usize>, req: HttpRequest) -> impl Responde
} }
// a successful version of a webhook // a successful version of a webhook
// now the more idiomatic way of sending a json
// #[get("/test_reqwest")] // #[get("/test_reqwest")]
// pub async fn test_reqwest(req: HttpRequest) -> impl Responder { // pub async fn test_reqwest(req: HttpRequest) -> impl Responder {
// log_incoming(req, "GET", "/test_reqwest"); // log_incoming(req, "GET", "/test_reqwest");
@ -121,13 +122,13 @@ pub async fn project(limit: web::Path<usize>, req: HttpRequest) -> impl Responde
// "content": "Hey, from Rust, welcome to <:discohook:736648398081622016> **Discohook**! The easiest way to personalise your Discord server.\n\nThere's more info below, but you don't have to read it. If you're ready press **Clear All** in the top of the editor to get started.\n\nDiscohook has a [support server](https://discohook.app/discord), if you need help feel free to join in and ask questions, suggest features, or just chat with the community.\n\nWe also have [complementary bot](https://discohook.app/bot) that may help out, featuring reaction roles and other utilities.\n_ _" // "content": "Hey, from Rust, welcome to <:discohook:736648398081622016> **Discohook**! The easiest way to personalise your Discord server.\n\nThere's more info below, but you don't have to read it. If you're ready press **Clear All** in the top of the editor to get started.\n\nDiscohook has a [support server](https://discohook.app/discord), if you need help feel free to join in and ask questions, suggest features, or just chat with the community.\n\nWe also have [complementary bot](https://discohook.app/bot) that may help out, featuring reaction roles and other utilities.\n_ _"
// }); // });
// let json_to_send = serde_json::to_string(&json_to_send).unwrap(); // // let json_to_send = serde_json::to_string(&json_to_send).unwrap();
// let client = Client::new(); // let client = Client::new();
// let res = client // let res = client
// .post("https://discord.com/api/webhooks/1369370183541461072/tuO93OJvdUsDzbHMBwHtQex11ijpfYLZMOvMov84eUPH5or3ziU03aOUmTZkfuibdhUp") // .post("https://discord.com/api/webhooks/1369370183541461072/tuO93OJvdUsDzbHMBwHtQex11ijpfYLZMOvMov84eUPH5or3ziU03aOUmTZkfuibdhUp")
// .header("Content-Type", "application/json") // // .header("Content-Type", "application/json")
// .body(json_to_send) // .json(&json_to_send)
// .send() // .send()
// .await; // .await;
// match res { // match res {