aboutsummaryrefslogtreecommitdiffstats
path: root/rust/src
diff options
context:
space:
mode:
Diffstat (limited to 'rust/src')
-rw-r--r--rust/src/bin/fatcat-auth.rs8
-rw-r--r--rust/src/bin/fatcat-export.rs10
-rw-r--r--rust/src/bin/fatcatd.rs6
-rw-r--r--rust/src/editing.rs6
-rw-r--r--rust/src/endpoints.rs4
-rw-r--r--rust/src/entity_crud.rs4
-rw-r--r--rust/src/lib.rs1
-rw-r--r--rust/src/server.rs6
8 files changed, 21 insertions, 24 deletions
diff --git a/rust/src/bin/fatcat-auth.rs b/rust/src/bin/fatcat-auth.rs
index 9efd47ed..85132023 100644
--- a/rust/src/bin/fatcat-auth.rs
+++ b/rust/src/bin/fatcat-auth.rs
@@ -2,11 +2,9 @@
use clap::{App, SubCommand};
-use fatcat::auth;
-use fatcat::editing;
-use fatcat::errors::*;
+use fatcat::{auth, editing, server};
+use fatcat::errors::Result;
use fatcat::identifiers::FatcatId;
-use fatcat::server::*;
use std::process;
use std::str::FromStr;
@@ -68,7 +66,7 @@ fn main() -> Result<()> {
}
// Then the ones that do
- let db_conn = database_worker_pool()?.get().expect("database pool");
+ let db_conn = server::database_worker_pool()?.get().expect("database pool");
let confectionary = auth::env_confectionary()?;
match m.subcommand() {
("list-editors", Some(_subm)) => {
diff --git a/rust/src/bin/fatcat-export.rs b/rust/src/bin/fatcat-export.rs
index 82f40048..d6764dc6 100644
--- a/rust/src/bin/fatcat-export.rs
+++ b/rust/src/bin/fatcat-export.rs
@@ -13,17 +13,15 @@ extern crate failure;
use clap::{App, Arg};
use fatcat::entity_crud::*;
-use fatcat::errors::*;
-use fatcat::identifiers::*;
-use fatcat::server::*;
+use fatcat::errors::Result;
+use fatcat::identifiers::FatcatId;
+use fatcat::server::{DbConn, self};
use fatcat_api_spec::models::*;
use std::str::FromStr;
use uuid::Uuid;
use std::thread;
-//use std::io::{Stdout,StdoutLock};
use crossbeam_channel as channel;
-//use num_cpus; TODO:
use std::io::prelude::*;
use std::io::{BufReader, BufWriter};
@@ -158,7 +156,7 @@ pub fn do_export(
entity_type: ExportEntityType,
redirects: bool,
) -> Result<()> {
- let db_pool = database_worker_pool()?;
+ let db_pool = server::database_worker_pool()?;
let buf_input = BufReader::new(std::io::stdin());
let (row_sender, row_receiver) = channel::bounded(CHANNEL_BUFFER_LEN);
let (output_sender, output_receiver) = channel::bounded(CHANNEL_BUFFER_LEN);
diff --git a/rust/src/bin/fatcatd.rs b/rust/src/bin/fatcatd.rs
index df5c390e..816ea1f0 100644
--- a/rust/src/bin/fatcatd.rs
+++ b/rust/src/bin/fatcatd.rs
@@ -6,8 +6,8 @@ extern crate slog;
extern crate hyper;
use clap::{App, Arg};
-use fatcat::errors::*;
-use fatcat::server::*;
+use fatcat::errors::Result;
+use fatcat::server;
use iron::middleware::AfterMiddleware;
use iron::modifiers::RedirectRaw;
use iron::{status, Chain, Iron, IronResult, Request, Response};
@@ -64,7 +64,7 @@ fn main() -> Result<()> {
None
};
- let mut server = create_server()?;
+ let mut server = server::create_server()?;
// metrics reporting
match env::var("FATCAT_STATSD_HOST") {
diff --git a/rust/src/editing.rs b/rust/src/editing.rs
index 2dfabc75..9dac30ac 100644
--- a/rust/src/editing.rs
+++ b/rust/src/editing.rs
@@ -1,9 +1,9 @@
use crate::database_models::*;
use crate::database_schema::*;
use crate::entity_crud::EntityCrud;
-use crate::errors::*;
-use crate::identifiers::*;
-use crate::server::*;
+use crate::errors::{Result, FatcatError};
+use crate::identifiers::{FatcatId, check_username};
+use crate::server::DbConn;
use diesel;
use diesel::prelude::*;
use fatcat_api_spec::models::*;
diff --git a/rust/src/endpoints.rs b/rust/src/endpoints.rs
index 027e25bc..8c7700f1 100644
--- a/rust/src/endpoints.rs
+++ b/rust/src/endpoints.rs
@@ -7,12 +7,12 @@
// using closures as a Result/? hack
#![allow(clippy::redundant_closure_call)]
-use crate::auth::*;
+use crate::auth::FatcatRole;
use crate::database_models::EntityEditRow;
use crate::editing::*;
use crate::entity_crud::{EntityCrud, ExpandFlags, HideFlags};
use crate::errors::*;
-use crate::identifiers::*;
+use crate::identifiers::FatcatId;
use crate::server::*;
use diesel::Connection;
use fatcat_api_spec::models;
diff --git a/rust/src/entity_crud.rs b/rust/src/entity_crud.rs
index 0c1e29b0..a0101de8 100644
--- a/rust/src/entity_crud.rs
+++ b/rust/src/entity_crud.rs
@@ -1,10 +1,10 @@
use crate::database_models::*;
use crate::database_schema::*;
-use crate::editing::*;
+use crate::editing::EditContext;
use crate::endpoint_handlers::get_release_files;
use crate::errors::*;
use crate::identifiers::*;
-use crate::server::*;
+use crate::server::DbConn;
use chrono;
use diesel::prelude::*;
use diesel::{self, insert_into};
diff --git a/rust/src/lib.rs b/rust/src/lib.rs
index eeb7e83f..b7661334 100644
--- a/rust/src/lib.rs
+++ b/rust/src/lib.rs
@@ -14,6 +14,7 @@ pub mod auth;
pub mod database_models;
pub mod database_schema; // only public for tests
pub mod editing;
+pub mod editing_crud;
mod endpoint_handlers;
mod endpoints;
pub mod entity_crud;
diff --git a/rust/src/server.rs b/rust/src/server.rs
index 66b215fc..c7cfa363 100644
--- a/rust/src/server.rs
+++ b/rust/src/server.rs
@@ -1,7 +1,7 @@
//! API endpoint handlers
-use crate::auth::*;
-use crate::errors::*;
+use crate::auth::{AuthConfectionary, self};
+use crate::errors::Result;
use chrono;
use diesel;
use diesel::pg::PgConnection;
@@ -44,7 +44,7 @@ pub fn create_server() -> Result<Server> {
let db_pool = diesel::r2d2::Pool::builder()
.build(manager)
.expect("Failed to create database pool.");
- let auth_confectionary = env_confectionary()?;
+ let auth_confectionary = auth::env_confectionary()?;
let metrics = StatsdClient::from_sink("blackhole", NopMetricSink);
Ok(Server {
db_pool,