Initial Commit
This commit is contained in:
commit
c97174301b
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
/target
|
||||
*.un~
|
||||
*~
|
1984
Cargo.lock
generated
Normal file
1984
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
10
Cargo.toml
Normal file
10
Cargo.toml
Normal file
|
@ -0,0 +1,10 @@
|
|||
[package]
|
||||
name = "milimate"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
rocket = "0.5.0"
|
||||
rocket_db_pools = { version = "0.1.0", features = ["diesel_postgres"] }
|
4
Rocket.toml
Normal file
4
Rocket.toml
Normal file
|
@ -0,0 +1,4 @@
|
|||
|
||||
|
||||
[default.databases.catsen]
|
||||
url = "./db.sqlite"
|
24
src/db.rs
Normal file
24
src/db.rs
Normal file
|
@ -0,0 +1,24 @@
|
|||
use rocket_db_pools::{Database, Connection};
|
||||
use rocket_db_pools::diesel::{QueryResult, PgPool, prelude::*};
|
||||
|
||||
#[derive(Database)]
|
||||
#[database("public")]
|
||||
pub stuct PublicDb(PgPool);
|
||||
|
||||
#[derive(Queryable, Insertable)]
|
||||
#[diesel(table_name = avatar)]
|
||||
pub struct Avatar {
|
||||
id: i64,
|
||||
ident: char,
|
||||
data: Vec<u8>,
|
||||
hash: Vec<u8>,
|
||||
}
|
||||
|
||||
diesel::table! {
|
||||
avatar (id) {
|
||||
id -> BigInt,
|
||||
ident -> Char,
|
||||
data -> Array<u8>,
|
||||
hash -> Array<u8>,
|
||||
}
|
||||
}
|
14
src/main.rs
Normal file
14
src/main.rs
Normal file
|
@ -0,0 +1,14 @@
|
|||
#[macro_use] extern crate rocket;
|
||||
use db::{PublicDb, Avatar};
|
||||
|
||||
mod db;
|
||||
|
||||
#[get("/")]
|
||||
async fn list(mut db: Connection<PublicDb>) -> QueryResult<String> {
|
||||
avatar::table.load(&mut db)
|
||||
}
|
||||
|
||||
#[launch]
|
||||
fn rocket() -> _ {
|
||||
rocket::build().mount("/", routes![index])
|
||||
}
|
Loading…
Reference in New Issue
Block a user