2021-03-20 02:31:41 +00:00
|
|
|
#![feature(proc_macro_hygiene, decl_macro)]
|
|
|
|
|
|
|
|
#[macro_use] extern crate rocket;
|
2021-03-26 22:30:38 +00:00
|
|
|
#[macro_use] extern crate rocket_contrib;
|
|
|
|
#[macro_use] extern crate diesel;
|
|
|
|
|
2021-04-02 20:09:51 +00:00
|
|
|
use trust_dns_client::client::SyncClient;
|
2021-03-20 02:31:41 +00:00
|
|
|
use trust_dns_client::tcp::TcpClientConnection;
|
|
|
|
|
2021-03-20 18:18:08 +00:00
|
|
|
mod models;
|
2021-03-20 02:31:41 +00:00
|
|
|
mod config;
|
2021-03-26 22:30:38 +00:00
|
|
|
mod schema;
|
2021-04-02 20:09:51 +00:00
|
|
|
mod routes;
|
2021-03-20 02:31:41 +00:00
|
|
|
|
2021-04-02 20:09:51 +00:00
|
|
|
use routes::users::*;
|
|
|
|
use routes::zones::*;
|
2021-03-26 22:30:38 +00:00
|
|
|
|
2021-03-20 18:18:08 +00:00
|
|
|
|
2021-03-26 22:30:38 +00:00
|
|
|
#[database("db")]
|
|
|
|
pub struct DbConn(diesel::SqliteConnection);
|
2021-03-20 02:31:41 +00:00
|
|
|
|
2021-04-02 20:09:51 +00:00
|
|
|
type DnsClient = SyncClient<TcpClientConnection>;
|
2021-04-02 17:33:59 +00:00
|
|
|
|
2021-03-20 02:31:41 +00:00
|
|
|
|
2021-04-02 17:33:59 +00:00
|
|
|
#[launch]
|
|
|
|
fn rocket() -> rocket::Rocket {
|
2021-03-20 02:31:41 +00:00
|
|
|
let app_config = config::load("config.toml".into());
|
2021-03-27 17:23:19 +00:00
|
|
|
println!("{:#?}", app_config);
|
2021-03-20 02:31:41 +00:00
|
|
|
|
2021-03-27 17:23:19 +00:00
|
|
|
let conn = TcpClientConnection::new(app_config.dns.server).unwrap();
|
2021-03-20 02:31:41 +00:00
|
|
|
let client = SyncClient::new(conn);
|
|
|
|
|
|
|
|
rocket::ignite()
|
|
|
|
.manage(client)
|
2021-03-27 17:23:19 +00:00
|
|
|
.manage(app_config)
|
2021-03-26 22:30:38 +00:00
|
|
|
.attach(DbConn::fairing())
|
2021-04-02 17:33:59 +00:00
|
|
|
.mount("/api/v1", routes![get_zone_records, create_auth_token, create_user])
|
2021-03-20 02:31:41 +00:00
|
|
|
}
|