Skip to content

Commit

Permalink
Update dropshot
Browse files Browse the repository at this point in the history
  • Loading branch information
augustuswm committed Nov 15, 2024
1 parent de98b18 commit 681df8a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
24 changes: 14 additions & 10 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ crc32c = "0.6.8"
diesel = { version = "2.2.4", features = ["postgres"] }
diesel_migrations = { version = "2.2.0" }
dirs = "5.0.1"
dropshot = "0.12.0"
dropshot = "0.13.0"
dropshot-verified-body = { git = "https://github.com/oxidecomputer/dropshot-verified-body" }
futures = "0.3.31"
google-drive3 = "6"
Expand Down
1 change: 1 addition & 0 deletions rfd-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ rfd-model = { path = "../rfd-model" }
rsa = { workspace = true, features = ["sha2"] }
schemars = { workspace = true, features = ["chrono"] }
secrecy = { workspace = true, features = ["serde"] }
semver = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
serde_urlencoded = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion rfd-api/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ async fn main() -> anyhow::Result<()> {
.expect("Failed to construct server")
.start();

server
server?
.await
.tap_err(|err| {
tracing::error!(?err, "Server exited with an error");
Expand Down
9 changes: 5 additions & 4 deletions rfd-api/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use dropshot::{
ApiDescription, ConfigDropshot, EndpointTagPolicy, HttpServerStarter, TagConfig, TagDetails,
ApiDescription, ConfigDropshot, EndpointTagPolicy, ServerBuilder, TagConfig, TagDetails,
};
use semver::Version;
use serde::Deserialize;
use slog::Drain;
use std::{collections::HashMap, error::Error, fs::File, net::SocketAddr, path::PathBuf};
Expand Down Expand Up @@ -42,7 +43,7 @@ v_system_endpoints!(RfdContext, RfdPermission);

pub fn server(
config: ServerConfig,
) -> Result<HttpServerStarter<RfdContext>, Box<dyn Error + Send + Sync>> {
) -> Result<ServerBuilder<RfdContext>, Box<dyn Error + Send + Sync>> {
let mut config_dropshot = ConfigDropshot::default();
config_dropshot.bind_address = config.server_address;
config_dropshot.request_body_max_bytes = 1024 * 1024;
Expand Down Expand Up @@ -102,7 +103,7 @@ pub fn server(
// panics if the file path is not a valid path

// Create the API schema.
let mut api_definition = &mut api.openapi(spec.title, &"");
let mut api_definition = &mut api.openapi(spec.title, Version::parse(env!("CARGO_PKG_VERSION"))?);
api_definition = api_definition
.description(spec.description)
.contact_url(spec.contact_url)
Expand All @@ -112,5 +113,5 @@ pub fn server(
api_definition.write(&mut buffer).unwrap();
}

HttpServerStarter::new(&config_dropshot, api, config.context, &dropshot_logger)
Ok(ServerBuilder::new(api, config.context, dropshot_logger).config(config_dropshot))
}

0 comments on commit 681df8a

Please sign in to comment.