diff --git a/Cargo.toml b/Cargo.toml index 800f469..dc76e62 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,3 +8,11 @@ actix-web = "4" serde = { version = "1.0", features = ["derive"] } serde_json = "1" yaml-rust2 = "0.10.1" +reqwest = "0.12.15" + +[profile.release] +debug = false +lto = "fat" +codegen-units = 1 +split-debuginfo = "off" +panic = "abort" diff --git a/data_txt/test.md b/data_txt/test.md new file mode 100644 index 0000000..e69de29 diff --git a/src/lib.rs b/src/lib.rs index 26d5c8a..d879d93 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,6 @@ -use actix_web::{HttpRequest, Responder, get, web}; +use actix_web::{HttpRequest, HttpResponse, Responder, get, web}; // use actix_web::{HttpResponse, post}; +use reqwest::Client; use serde::{Deserialize, Serialize}; use serde_json::json; use std::fs; @@ -112,6 +113,30 @@ pub async fn project(limit: web::Path, req: HttpRequest) -> impl Responde web::Json(res_vec) } +// a successful version of a webhook +// #[get("/test_reqwest")] +// pub async fn test_reqwest(req: HttpRequest) -> impl Responder { +// log_incoming(req, "GET", "/test_reqwest"); +// let json_to_send = serde_json::json!({ +// "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 client = Client::new(); +// let res = client +// .post("https://discord.com/api/webhooks/1369370183541461072/tuO93OJvdUsDzbHMBwHtQex11ijpfYLZMOvMov84eUPH5or3ziU03aOUmTZkfuibdhUp") +// .header("Content-Type", "application/json") +// .body(json_to_send) +// .send() +// .await; +// match res { +// Ok(response) => println!("Success: {:#?}", response), +// Err(e) => eprintln!("Error sending request: {}", e), +// } +// HttpResponse::Ok().body("Hello there!\nGeneral Kenobi") +// } + // #[cfg(test)] // mod tests { // use super::*; @@ -120,5 +145,6 @@ pub async fn project(limit: web::Path, req: HttpRequest) -> impl Responde // fn it_works() { // let result = add(2, 2); // assert_eq!(result, 4); +// test_reqwest(); // } // } diff --git a/src/main.rs b/src/main.rs index 9a0f089..624f41d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ use actix_web::{App, HttpServer, web}; -use darkicewolf50_cloud::{hello, project, skills_home}; +use darkicewolf50_cloud::{hello, project, skills_home, test_reqwest}; // use darkicewolf50_cloud:: {echo, manual_hello, resend,}; #[actix_web::main] @@ -12,6 +12,7 @@ async fn main() -> std::io::Result<()> { // .service(resend) // .route("/hey", web::get().to(manual_hello)) .service(project) + .service(test_reqwest) .service(web::scope("/home").service(skills_home)) }) .bind(("127.0.0.1", 8080))?