Skip to content

Commit

Permalink
Merge pull request #43 from aaronriekenberg/main
Browse files Browse the repository at this point in the history
Step up to hyper 1.0.0-rc.4
  • Loading branch information
stephank authored Jul 18, 2023
2 parents 48d722f + 41076ac commit 1513079
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ futures-util = "0.3.1"
http = "0.2.0"
httpdate = "1.0.1"
http-range = "0.1.4"
hyper = "1.0.0-rc.1"
hyper = "1.0.0-rc.4"
mime_guess = "2.0.1"
percent-encoding = "2.1.0"
rand = "0.8.4"
tokio = { version = "1.0.0", features = ["fs"] }
url = "2.1.0"

[dev-dependencies]
hyper = { version = "1.0.0-rc.1", features = ["http1", "server"] }
http-body-util = "0.1.0-rc.1"
hyper = { version = "1.0.0-rc.4", features = ["http1", "server"] }
hyper-util = { git = "https://github.com/hyperium/hyper-util.git" }
http-body-util = "0.1.0-rc.3"
tempfile = "3"
tokio = { version = "1.0.0", features = ["macros", "rt-multi-thread", "net", "io-util"] }

Expand Down
3 changes: 2 additions & 1 deletion examples/doc_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use http::{header, StatusCode};
use hyper::service::service_fn;
use hyper::{Request, Response};
use hyper_staticfile::{Body, Static};
use hyper_util::rt::TokioIo;
use tokio::net::TcpListener;

async fn handle_request<B>(req: Request<B>, static_: Static) -> Result<Response<Body>, IoError> {
Expand Down Expand Up @@ -46,7 +47,7 @@ async fn main() {
tokio::spawn(async move {
if let Err(err) = hyper::server::conn::http1::Builder::new()
.serve_connection(
stream,
TokioIo::new(stream),
service_fn(move |req| handle_request(req, static_.clone())),
)
.await
Expand Down
2 changes: 1 addition & 1 deletion src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ where
type Error = IoError;
type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send>>;

fn call(&mut self, request: Request<B>) -> Self::Future {
fn call(&self, request: Request<B>) -> Self::Future {
Box::pin(self.clone().serve(request))
}
}
5 changes: 4 additions & 1 deletion tests/hyper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ use std::path::Path;

use hyper_staticfile::Static;

use hyper_util::rt::TokioIo;

// This test currently only demonstrates that a `Static` instance can be used
// as a hyper service directly.
#[tokio::test]
async fn test_usable_as_hyper_service() {
let static_ = Static::new(Path::new("target/doc/"));

let (stream, _) = tokio::io::duplex(2);
let fut = hyper::server::conn::http1::Builder::new().serve_connection(stream, static_);
let fut =
hyper::server::conn::http1::Builder::new().serve_connection(TokioIo::new(stream), static_);

// It's enough to show that this builds, so no need to execute anything.
drop(fut);
Expand Down

0 comments on commit 1513079

Please sign in to comment.