Added new models + establish_connection function
This commit is contained in:
parent
5039fa32db
commit
d78e4bd988
|
@ -0,0 +1,8 @@
|
|||
use crate::helper::settings::Settings;
|
||||
use diesel::{Connection, PgConnection};
|
||||
use rocket::State;
|
||||
|
||||
pub fn establish_connection(settings: State<Settings>) -> PgConnection {
|
||||
let db_url = settings.database.connection_string.clone();
|
||||
PgConnection::establish(&db_url).expect(&format!("Error connecting to database."))
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
pub mod connector;
|
|
@ -0,0 +1,2 @@
|
|||
pub mod controller;
|
||||
pub mod model;
|
|
@ -0,0 +1,6 @@
|
|||
use diesel::pg::types::sql_types::Uuid;
|
||||
|
||||
#[derive(Queryable)]
|
||||
pub struct Entity {
|
||||
entity_id: Uuid,
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
pub mod addresses;
|
||||
pub mod entities;
|
||||
pub mod members;
|
||||
pub mod users;
|
25
src/main.rs
25
src/main.rs
|
@ -7,8 +7,12 @@ extern crate serde_derive;
|
|||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate lazy_static;
|
||||
#[macro_use] extern crate rocket;
|
||||
#[macro_use]
|
||||
extern crate rocket;
|
||||
#[macro_use]
|
||||
extern crate diesel;
|
||||
|
||||
pub mod database;
|
||||
pub mod helper;
|
||||
pub mod modules;
|
||||
|
||||
|
@ -18,14 +22,17 @@ use rocket::State;
|
|||
fn main() {
|
||||
env_logger::init(); //Initializes logger. Set environment variable RUST_LOG=debug|info|warn|error to set loglevel
|
||||
|
||||
let settings = match Settings::new(){
|
||||
Ok(settings) => settings,
|
||||
Err(e) => {
|
||||
error!("Failed to read config: {}", e);
|
||||
std::process::exit(1);
|
||||
}
|
||||
let settings = match Settings::new() {
|
||||
Ok(settings) => settings,
|
||||
Err(e) => {
|
||||
error!("Failed to read config: {}", e);
|
||||
std::process::exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
debug!("Hello, world! Default Language: {}", settings.application.default_language);
|
||||
debug!(
|
||||
"Hello, world! Default Language: {}",
|
||||
settings.application.default_language
|
||||
);
|
||||
rocket::ignite().manage(settings);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue