♻️ Remove the hyper dep from ptth_server.exe
parent
f4b0c64e01
commit
028970cdf0
|
@ -8,34 +8,14 @@ license = "AGPL-3.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
||||||
aho-corasick = "0.7.14"
|
|
||||||
anyhow = "1.0.34"
|
anyhow = "1.0.34"
|
||||||
base64 = "0.12.3"
|
|
||||||
blake3 = "0.3.7"
|
|
||||||
futures = "0.3.7"
|
|
||||||
handlebars = "3.5.1"
|
handlebars = "3.5.1"
|
||||||
http = "0.2.1"
|
http = "0.2.1"
|
||||||
hyper = "0.13.8"
|
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"]}
|
serde = {version = "1.0.117", features = ["derive"]}
|
||||||
structopt = "0.3.20"
|
structopt = "0.3.20"
|
||||||
thiserror = "1.0.22"
|
|
||||||
tokio = { version = "0.2.22", features = ["full"] }
|
tokio = { version = "0.2.22", features = ["full"] }
|
||||||
tracing = "0.1.21"
|
|
||||||
tracing-futures = "0.2.4"
|
|
||||||
tracing-subscriber = "0.2.15"
|
tracing-subscriber = "0.2.15"
|
||||||
toml = "0.5.7"
|
|
||||||
|
|
||||||
always_equal = { path = "../always_equal" }
|
|
||||||
ptth_core = { path = "../ptth_core" }
|
ptth_core = { path = "../ptth_core" }
|
||||||
ptth_server = { path = "../ptth_server" }
|
ptth_server = { path = "../ptth_server" }
|
||||||
|
|
||||||
[dev-dependencies]
|
|
||||||
|
|
||||||
maplit = "1.0.2"
|
|
||||||
rand = "0.6.5"
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ use ptth_core::{
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
use ptth_server::{
|
use ptth_server::{
|
||||||
errors::ServerError,
|
|
||||||
file_server,
|
file_server,
|
||||||
load_toml,
|
load_toml,
|
||||||
};
|
};
|
||||||
|
@ -42,7 +41,7 @@ struct ServerState <'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_all (req: Request <Body>, state: Arc <ServerState <'static>>)
|
async fn handle_all (req: Request <Body>, state: Arc <ServerState <'static>>)
|
||||||
-> Result <Response <Body>, ServerError>
|
-> Result <Response <Body>, anyhow::Error>
|
||||||
{
|
{
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ blake3 = "0.3.7"
|
||||||
futures = "0.3.7"
|
futures = "0.3.7"
|
||||||
handlebars = "3.5.1"
|
handlebars = "3.5.1"
|
||||||
http = "0.2.1"
|
http = "0.2.1"
|
||||||
hyper = "0.13.8"
|
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
percent-encoding = "2.1.0"
|
percent-encoding = "2.1.0"
|
||||||
pulldown-cmark = "0.8.0"
|
pulldown-cmark = "0.8.0"
|
||||||
|
|
|
@ -32,13 +32,13 @@ pub enum ServerError {
|
||||||
// Hyper stuff
|
// Hyper stuff
|
||||||
|
|
||||||
#[error ("Hyper HTTP error")]
|
#[error ("Hyper HTTP error")]
|
||||||
Http (#[from] hyper::http::Error),
|
Http (#[from] http::Error),
|
||||||
|
|
||||||
#[error ("Hyper invalid header name")]
|
//#[error ("Hyper invalid header name")]
|
||||||
InvalidHeaderName (#[from] hyper::header::InvalidHeaderName),
|
//InvalidHeaderName (#[from] hyper::header::InvalidHeaderName),
|
||||||
|
|
||||||
#[error ("API key invalid")]
|
#[error ("API key invalid")]
|
||||||
ApiKeyInvalid (hyper::header::InvalidHeaderValue),
|
ApiKeyInvalid (http::header::InvalidHeaderValue),
|
||||||
|
|
||||||
// MessagePack stuff
|
// MessagePack stuff
|
||||||
|
|
||||||
|
|
|
@ -33,5 +33,5 @@ pub enum FileServerError {
|
||||||
Markdown (#[from] MarkdownError),
|
Markdown (#[from] MarkdownError),
|
||||||
|
|
||||||
#[error ("Invalid URI")]
|
#[error ("Invalid URI")]
|
||||||
InvalidUri (#[from] hyper::http::uri::InvalidUri),
|
InvalidUri (#[from] http::uri::InvalidUri),
|
||||||
}
|
}
|
||||||
|
|
|
@ -468,7 +468,7 @@ fn internal_serve_dir (
|
||||||
path: &Path,
|
path: &Path,
|
||||||
dir: tokio::fs::ReadDir,
|
dir: tokio::fs::ReadDir,
|
||||||
full_path: PathBuf,
|
full_path: PathBuf,
|
||||||
uri: &hyper::Uri
|
uri: &http::Uri
|
||||||
)
|
)
|
||||||
-> Result <InternalResponse, FileServerError>
|
-> Result <InternalResponse, FileServerError>
|
||||||
{
|
{
|
||||||
|
@ -494,7 +494,7 @@ fn internal_serve_dir (
|
||||||
|
|
||||||
async fn internal_serve_file (
|
async fn internal_serve_file (
|
||||||
mut file: tokio::fs::File,
|
mut file: tokio::fs::File,
|
||||||
uri: &hyper::Uri,
|
uri: &http::Uri,
|
||||||
send_body: bool,
|
send_body: bool,
|
||||||
headers: &HashMap <String, Vec <u8>>
|
headers: &HashMap <String, Vec <u8>>
|
||||||
)
|
)
|
||||||
|
@ -571,7 +571,7 @@ async fn internal_serve_all (
|
||||||
|
|
||||||
info! ("Client requested {}", uri);
|
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 {
|
let send_body = match &method {
|
||||||
Method::Get => true,
|
Method::Get => true,
|
||||||
|
|
|
@ -210,9 +210,7 @@ fn file_server () {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_uri () {
|
fn parse_uri () {
|
||||||
use hyper::Uri;
|
assert! (http::Uri::from_maybe_shared ("/").is_ok ());
|
||||||
|
|
||||||
assert! (Uri::from_maybe_shared ("/").is_ok ());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -15,7 +15,7 @@ use std::{
|
||||||
|
|
||||||
use futures::FutureExt;
|
use futures::FutureExt;
|
||||||
use handlebars::Handlebars;
|
use handlebars::Handlebars;
|
||||||
use hyper::{
|
use http::status::{
|
||||||
StatusCode,
|
StatusCode,
|
||||||
};
|
};
|
||||||
use reqwest::Client;
|
use reqwest::Client;
|
||||||
|
|
Loading…
Reference in New Issue