initial commit

This commit is contained in:
DJMrTV 2025-02-23 19:33:55 +01:00
commit d4143caf16
7 changed files with 1706 additions and 0 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/target
.idea

1642
Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

11
Cargo.toml Normal file
View file

@ -0,0 +1,11 @@
[package]
name = "account"
version = "0.1.0"
edition = "2021"
[dependencies]
rocket = "0.5.1"
serde = { version = "1.0.218", features = ["derive"] }
log = "0.4.26"
quick-xml = { version = "0.37.2", features = ["serialize"] }
tokio = "1.43.0"

10
res/conntest.html Normal file
View file

@ -0,0 +1,10 @@
<!DOCTYPE html PUBLIC "-// *W3C// *DTD XHTML 1.0 Transitional// *EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>HTML Page</title>
</head>
<body bgcolor="#FFFFFF">
This is test.html page
</body>
</html>

7
src/conntest.rs Normal file
View file

@ -0,0 +1,7 @@
use rocket::get;
use rocket::response::content::RawHtml;
#[get("/")]
pub fn conntest() -> RawHtml<&'static str>{
RawHtml(include_str!("../res/conntest.html"))
}

10
src/main.rs Normal file
View file

@ -0,0 +1,10 @@
use rocket::routes;
mod xml;
mod conntest;
#[rocket::launch]
async fn launch() -> _ {
rocket::build()
.mount("/", routes![conntest::conntest])
}

24
src/xml.rs Normal file
View file

@ -0,0 +1,24 @@
use rocket::http::Status;
use rocket::Request;
use rocket::response::Responder;
use serde::Serialize;
use rocket::response::Result;
use log::error;
use rocket::response::content::RawXml;
#[derive(Debug)]
pub struct Xml<T>(pub T);
impl<'r, 'o: 'r, T: Serialize> Responder<'r, 'o> for Xml<T>{
fn respond_to(self, request: &'r Request<'_>) -> Result<'o> {
match quick_xml::se::to_string(&self.0){
Ok(ser) => {
RawXml(ser).respond_to(request)
},
Err(e) => {
error!("serialization error: {}", e);
Err(Status::InternalServerError)
}
}
}
}