feat(master): added opimizations to porfile and added sucessful version of using reqwest to send a wehook to discord
This commit is contained in:
parent
169071af8c
commit
52ae1bb1e2
@ -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"
|
||||
|
0
data_txt/test.md
Normal file
0
data_txt/test.md
Normal file
28
src/lib.rs
28
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<usize>, 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<usize>, req: HttpRequest) -> impl Responde
|
||||
// fn it_works() {
|
||||
// let result = add(2, 2);
|
||||
// assert_eq!(result, 4);
|
||||
// test_reqwest();
|
||||
// }
|
||||
// }
|
||||
|
@ -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))?
|
||||
|
Loading…
x
Reference in New Issue
Block a user