♻️ Remove the hyper dep from ptth_server.exe

main
_ 2020-11-29 21:55:24 +00:00
parent f4b0c64e01
commit 028970cdf0
8 changed files with 11 additions and 35 deletions

View File

@ -8,34 +8,14 @@ license = "AGPL-3.0"
[dependencies]
aho-corasick = "0.7.14"
anyhow = "1.0.34"
base64 = "0.12.3"
blake3 = "0.3.7"
futures = "0.3.7"
handlebars = "3.5.1"
http = "0.2.1"
hyper = "0.13.8"
lazy_static = "1.4.0"
percent-encoding = "2.1.0"
pulldown-cmark = "0.8.0"
regex = "1.4.1"
reqwest = { version = "0.10.8", features = ["stream"] }
rmp-serde = "0.14.4"
serde = {version = "1.0.117", features = ["derive"]}
structopt = "0.3.20"
thiserror = "1.0.22"
tokio = { version = "0.2.22", features = ["full"] }
tracing = "0.1.21"
tracing-futures = "0.2.4"
tracing-subscriber = "0.2.15"
toml = "0.5.7"
always_equal = { path = "../always_equal" }
ptth_core = { path = "../ptth_core" }
ptth_server = { path = "../ptth_server" }
[dev-dependencies]
maplit = "1.0.2"
rand = "0.6.5"

View File

@ -24,7 +24,6 @@ use ptth_core::{
prelude::*,
};
use ptth_server::{
errors::ServerError,
file_server,
load_toml,
};
@ -42,7 +41,7 @@ struct ServerState <'a> {
}
async fn handle_all (req: Request <Body>, state: Arc <ServerState <'static>>)
-> Result <Response <Body>, ServerError>
-> Result <Response <Body>, anyhow::Error>
{
use std::str::FromStr;

View File

@ -15,7 +15,6 @@ blake3 = "0.3.7"
futures = "0.3.7"
handlebars = "3.5.1"
http = "0.2.1"
hyper = "0.13.8"
lazy_static = "1.4.0"
percent-encoding = "2.1.0"
pulldown-cmark = "0.8.0"

View File

@ -32,13 +32,13 @@ pub enum ServerError {
// Hyper stuff
#[error ("Hyper HTTP error")]
Http (#[from] hyper::http::Error),
Http (#[from] http::Error),
#[error ("Hyper invalid header name")]
InvalidHeaderName (#[from] hyper::header::InvalidHeaderName),
//#[error ("Hyper invalid header name")]
//InvalidHeaderName (#[from] hyper::header::InvalidHeaderName),
#[error ("API key invalid")]
ApiKeyInvalid (hyper::header::InvalidHeaderValue),
ApiKeyInvalid (http::header::InvalidHeaderValue),
// MessagePack stuff

View File

@ -33,5 +33,5 @@ pub enum FileServerError {
Markdown (#[from] MarkdownError),
#[error ("Invalid URI")]
InvalidUri (#[from] hyper::http::uri::InvalidUri),
InvalidUri (#[from] http::uri::InvalidUri),
}

View File

@ -468,7 +468,7 @@ fn internal_serve_dir (
path: &Path,
dir: tokio::fs::ReadDir,
full_path: PathBuf,
uri: &hyper::Uri
uri: &http::Uri
)
-> Result <InternalResponse, FileServerError>
{
@ -494,7 +494,7 @@ fn internal_serve_dir (
async fn internal_serve_file (
mut file: tokio::fs::File,
uri: &hyper::Uri,
uri: &http::Uri,
send_body: bool,
headers: &HashMap <String, Vec <u8>>
)
@ -571,7 +571,7 @@ async fn internal_serve_all (
info! ("Client requested {}", uri);
let uri = hyper::Uri::from_str (uri).map_err (FileServerError::InvalidUri)?;
let uri = http::Uri::from_str (uri).map_err (FileServerError::InvalidUri)?;
let send_body = match &method {
Method::Get => true,

View File

@ -210,9 +210,7 @@ fn file_server () {
#[test]
fn parse_uri () {
use hyper::Uri;
assert! (Uri::from_maybe_shared ("/").is_ok ());
assert! (http::Uri::from_maybe_shared ("/").is_ok ());
}
#[test]

View File

@ -15,7 +15,7 @@ use std::{
use futures::FutureExt;
use handlebars::Handlebars;
use hyper::{
use http::status::{
StatusCode,
};
use reqwest::Client;