Skip to content

Commit

Permalink
upgrade to hyper v1 (#1028)
Browse files Browse the repository at this point in the history
Co-authored-by: David Pacheco <dap@oxidecomputer.com>
Co-authored-by: Adam H. Leventhal <ahl@oxide.computer>
  • Loading branch information
3 people authored Sep 26, 2024
1 parent db7b377 commit 37dc307
Show file tree
Hide file tree
Showing 39 changed files with 661 additions and 346 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@

https://github.com/oxidecomputer/dropshot/compare/v0.11.0\...HEAD[Full list of commits]

=== Breaking Changes

* https://github.com/oxidecomputer/dropshot/pull/1028[#1028] Updates Dropshot for `hyper` 1.0 and `http` 1.0. Since consumers provide Dropshot with values from `hyper` and `http`, you'll need to update to `hyper` 1.0 and `http` 1.0 (or newer compatible versions), too.

==== Upgrading to hyper 1.0

1. Update your crate's dependencies on `hyper` and `http` to 1.0 (or a newer compatible version) in Cargo.toml.
2. Replace any references to `hyper::Body` with `dropshot::Body` instead.
3. You may need to update your use of `dropshot::Body`; the `http-body-util` can be helpful.

There are no other known breaking changes in these crates that affect Dropshot. If you have any trouble with this upgrade, please let us know by filing an issue.

== 0.11.0 (released 2024-08-21)

https://github.com/oxidecomputer/dropshot/compare/v0.10.1\...v0.11.0[Full list of commits]
Expand Down
99 changes: 55 additions & 44 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions dropshot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ debug-ignore = "1.0.5"
form_urlencoded = "1.2.1"
futures = "0.3.30"
hostname = "0.4.0"
http = "0.2.9"
http = "1.1.0"
http-body-util = "0.1.2"
indexmap = "2.5.0"
multer = "3.1.0"
paste = "1.0.15"
Expand Down Expand Up @@ -55,7 +56,11 @@ version = "^0.11.1-dev"
path = "../dropshot_endpoint"

[dependencies.hyper]
version = "0.14"
version = "1.4.1"
features = [ "full" ]

[dependencies.hyper-util]
version = "0.1.9"
features = [ "full" ]

[dependencies.openapiv3]
Expand Down Expand Up @@ -88,8 +93,8 @@ anyhow = "1.0.89"
async-channel = "2.3.1"
buf-list = "1.0.3"
expectorate = "1.1.0"
hyper-rustls = "0.25.0"
hyper-staticfile = "0.9"
hyper-rustls = "0.26.0"
hyper-staticfile = "0.10"
lazy_static = "1.5.0"
libc = "0.2.158"
mime_guess = "2.0.5"
Expand Down
10 changes: 7 additions & 3 deletions dropshot/examples/file_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
//! Example using Dropshot to serve files

use dropshot::ApiDescription;
use dropshot::Body;
use dropshot::ConfigLogging;
use dropshot::ConfigLoggingLevel;
use dropshot::HttpError;
use dropshot::HttpServerStarter;
use dropshot::RequestContext;
use dropshot::{endpoint, Path};
use http::{Response, StatusCode};
use hyper::Body;
use schemars::JsonSchema;
use serde::Deserialize;
use std::path::PathBuf;
Expand Down Expand Up @@ -133,7 +133,11 @@ async fn static_content(
format!("failed to read file {:?}: {:#}", entry, e),
)
})?;
let file_stream = hyper_staticfile::FileBytesStream::new(file);

let file_access = hyper_staticfile::vfs::TokioFileAccess::new(file);
let file_stream =
hyper_staticfile::util::FileBytesStream::new(file_access);
let body = Body::wrap(hyper_staticfile::Body::Full(file_stream));

// Derive the MIME type from the file name
let content_type = mime_guess::from_path(&entry)
Expand All @@ -143,7 +147,7 @@ async fn static_content(
Ok(Response::builder()
.status(StatusCode::OK)
.header(http::header::CONTENT_TYPE, content_type)
.body(file_stream.into_body())?)
.body(body)?)
}
}

Expand Down
2 changes: 1 addition & 1 deletion dropshot/examples/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//! Example use of Dropshot for matching wildcard paths to serve static content.

use dropshot::ApiDescription;
use dropshot::Body;
use dropshot::ConfigDropshot;
use dropshot::ConfigLogging;
use dropshot::ConfigLoggingLevel;
Expand All @@ -10,7 +11,6 @@ use dropshot::HttpServerStarter;
use dropshot::RequestContext;
use dropshot::{endpoint, Path};
use http::{Response, StatusCode};
use hyper::Body;
use schemars::JsonSchema;
use serde::Deserialize;

Expand Down
2 changes: 1 addition & 1 deletion dropshot/examples/multipart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use dropshot::endpoint;
use dropshot::ApiDescription;
use dropshot::Body;
use dropshot::ConfigDropshot;
use dropshot::ConfigLogging;
use dropshot::ConfigLoggingLevel;
Expand All @@ -11,7 +12,6 @@ use dropshot::HttpServerStarter;
use dropshot::MultipartBody;
use dropshot::RequestContext;
use http::{Response, StatusCode};
use hyper::Body;

#[tokio::main]
async fn main() -> Result<(), String> {
Expand Down
2 changes: 1 addition & 1 deletion dropshot/src/api_description.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1312,14 +1312,14 @@ mod test {
use crate::handler::RequestContext;
use crate::ApiDescription;
use crate::ApiEndpoint;
use crate::Body;
use crate::EndpointTagPolicy;
use crate::Path;
use crate::Query;
use crate::TagConfig;
use crate::TagDetails;
use crate::CONTENT_TYPE_JSON;
use http::Method;
use hyper::Body;
use hyper::Response;
use openapiv3::OpenAPI;
use schemars::JsonSchema;
Expand Down
Loading

0 comments on commit 37dc307

Please sign in to comment.