summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-05-20 11:24:57 +0200
committerMatthias Beyer <mail@beyermatthias.de>2020-05-20 11:24:57 +0200
commit63344dcff3a7f785c6bce8295c2aa3b4a9914d74 (patch)
tree11beb9a92454af9ee20c1bcfadba31cdc9363699
parent5bca05568622cdd7c9ad3a6f64a688e877dd8fca (diff)
parent4ab522da918ca6d15324e2ee5e7e9491e6f7fe88 (diff)
downloaddistrox-63344dcff3a7f785c6bce8295c2aa3b4a9914d74.tar.gz
distrox-63344dcff3a7f785c6bce8295c2aa3b4a9914d74.tar.xz
Merge branch 'app-is-middleware'
-rw-r--r--src/main.rs4
-rw-r--r--src/middleware.rs (renamed from src/app.rs)9
-rw-r--r--src/server.rs6
3 files changed, 10 insertions, 9 deletions
diff --git a/src/main.rs b/src/main.rs
index 0e91afd..80e6ec9 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -29,11 +29,11 @@ extern crate pidlock;
#[macro_use] extern crate add_getters_setters;
#[macro_use] extern crate structopt;
-mod app;
mod cli;
mod configuration;
mod gui;
mod model;
+mod middleware;
mod server;
mod types;
mod version;
@@ -54,10 +54,10 @@ use anyhow::Result;
use anyhow::Error;
use env_logger::Env;
-use crate::app::App;
use crate::cli::*;
use crate::configuration::Configuration;
use crate::model::Model;
+use crate::middleware::Middleware;
use crate::types::block::Block;
use crate::types::content::Content;
use crate::types::payload::Payload;
diff --git a/src/app.rs b/src/middleware.rs
index d356dca..61fe716 100644
--- a/src/app.rs
+++ b/src/middleware.rs
@@ -14,17 +14,18 @@ use crate::types::payload::Payload;
use crate::types::util::Timestamp;
use crate::version::protocol_version;
+/// The "Middleware" type implements the actual application logic
#[derive(Debug, Clone)]
-pub struct App {
+pub struct Middleware {
repo: Model,
device_name: IPNSHash,
publishing_key: String
}
-impl App {
+impl Middleware {
pub fn load(device_name: IPNSHash, publishing_key: String, host: &str, port: u16) -> Result<Self, Error> {
- Model::new(host, port).map(|repo| App { repo, device_name, publishing_key })
+ Model::new(host, port).map(|repo| Middleware { repo, device_name, publishing_key })
}
pub async fn new_profile(repo: Model, publishing_key: &str, names: Vec<String>) -> Result<Self, Error> {
@@ -40,7 +41,7 @@ impl App {
let head = repo.put_block(Block::new(protocol_version(), vec![], content_hash)).await?;
let device_name = repo.publish(&publishing_key, &head).await?;
- Ok(App { repo, device_name, publishing_key: publishing_key.to_string() })
+ Ok(Middleware { repo, device_name, publishing_key: publishing_key.to_string() })
}
pub async fn new_post(&self,
diff --git a/src/server.rs b/src/server.rs
index 0fc8e9b..b1fa237 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -8,9 +8,9 @@ use actix_web::Responder;
use actix_web::http::StatusCode;
use actix_web::body::Body;
-use crate::app::App;
use crate::cli::*;
use crate::configuration::Configuration;
+use crate::middleware::Middleware;
use crate::types::util::*;
pub fn mk_lock() -> Pidlock {
@@ -37,11 +37,11 @@ pub async fn run_server(config: Configuration, mut server_lock: Pidlock, adr: St
let api_url = config.get_api_url().clone();
let api_port = config.get_api_port().clone();
- App::load(name, key, &api_url, api_port)
+ Middleware::load(name, key, &api_url, api_port)
} else {
// ask user for name(s)
// boot repository
- // load App object
+ // load Middleware object
unimplemented!()
}
}?;