This repository has been archived on 2026-02-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
fadaway/src/main.rs
2023-05-27 18:32:20 +09:00

46 lines
1.1 KiB
Rust

mod apub;
mod ctx;
mod handler;
use rocket;
use ctx::db;
use ctx::user;
use ctx::Ctx;
use ctx::Config;
#[rocket::launch]
fn launch() -> _ {
let ctx = Ctx {
cfg: Config::load("fadaway.json").unwrap_or(Config::default()),
db : Box::new(FakeDB {}),
};
rocket::build().
manage(ctx).
mount("/.well-known/webfinger", rocket::routes![handler::webfinger::main]).
mount("/", rocket::routes![handler::actor::main])
}
pub struct FakeDB;
impl ctx::DB for FakeDB {
fn new(&self, d: &user::Id) -> Result<(), String> {
Err("not implemented".to_owned())
}
fn delete(&self, d: &user::Id) -> Result<(), String> {
Err("not implemented".to_owned())
}
fn exists(&self, d: &user::Id) -> Result<bool, String> {
Ok(true)
}
fn get_profile(&self, id: &user::Id) -> Result<user::Profile, db::ReadError> {
Ok(user::Profile {
name: id.name.to_owned(),
private: true,
})
}
fn set_profile(&self, id: &user::Id, d: user::Profile) -> Result<user::Profile, db::WriteError> {
Err(db::WriteError::Internal("not implemented".to_owned()))
}
}