summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-05-20 11:23:42 +0200
committerMatthias Beyer <mail@beyermatthias.de>2020-05-20 11:23:42 +0200
commit4ab522da918ca6d15324e2ee5e7e9491e6f7fe88 (patch)
tree1e82a4ac3b2ee010dcc11ebfabf9d99a63b91fd5
parentc44d69dcde20d6b200f7c2782a4ebbb848e2ed1f (diff)
downloaddistrox-4ab522da918ca6d15324e2ee5e7e9491e6f7fe88.tar.gz
distrox-4ab522da918ca6d15324e2ee5e7e9491e6f7fe88.tar.xz
Rename: App -> Middleware
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-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 b624bd8..8cc2a8f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -29,10 +29,10 @@ extern crate pidlock;
#[macro_use] extern crate add_getters_setters;
#[macro_use] extern crate structopt;
-mod app;
mod cli;
mod configuration;
mod gui;
+mod middleware;
mod repository;
mod server;
mod types;
@@ -54,9 +54,9 @@ use anyhow::Result;
use anyhow::Error;
use env_logger::Env;
-use crate::app::App;
use crate::cli::*;
use crate::configuration::Configuration;
+use crate::middleware::Middleware;
use crate::repository::repository::Repository;
use crate::types::block::Block;
use crate::types::content::Content;
diff --git a/src/app.rs b/src/middleware.rs
index b31839f..37ea7a2 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: Repository,
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> {
- Repository::new(host, port).map(|repo| App { repo, device_name, publishing_key })
+ Repository::new(host, port).map(|repo| Middleware { repo, device_name, publishing_key })
}
pub async fn new_profile(repo: Repository, 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!()
}
}?;