Skip to content

Commit 6c947e3

Browse files
committed
Switch to conduit-hyper in place of civet
`conduit-hyper` now handles normalizing paths, such that `//api/v1` becomes `/api/v1` and doesn't break our router.
1 parent 5130da6 commit 6c947e3

File tree

7 files changed

+26
-51
lines changed

7 files changed

+26
-51
lines changed

Cargo.lock

Lines changed: 16 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ rustdoc-args = [
2929

3030
[dependencies]
3131
cargo-registry-s3 = { path = "src/s3", version = "0.2.0" }
32-
old_semver = { path = "src/old_semver", version = "0.1.0" }
3332
rand = "0.3"
3433
git2 = "0.6.4"
3534
flate2 = "1.0"
@@ -75,7 +74,7 @@ conduit-middleware = "0.8"
7574
conduit-router = "0.8"
7675
conduit-static = "0.8"
7776
conduit-git-http-backend = "0.8"
78-
civet = "0.9"
77+
conduit-hyper = "0.1.3"
7978

8079
[dev-dependencies]
8180
conduit-test = "0.8"

docs/BACKEND.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ The server does the following things:
1212
3. Reads values from environment variables to configure a new instance of `cargo_registry::App`
1313
4. Adds middleware to the app by calling `cargo_registry::middleware`
1414
5. Syncs the categories defined in *src/categories.toml* with the categories in the database
15-
6. Starts a [civet][] `Server` that uses the `cargo_registry::App` instance
15+
6. Starts a [hyper] server that uses the `cargo_registry::App` instance
1616
7. Tells Nginx on Heroku that the application is ready to receive requests, if running on Heroku
17-
8. Blocks forever (or until the process is killed) waiting to receive messages on a channel that no
18-
messages are ever sent to, in order to outive the civet `Server` threads
17+
8. Blocks forever (or until the process is killed)
1918

20-
[civet]: https://crates.io/crates/civet
19+
[hyper]: https://crates.io/crates/hyper
2120

2221
## Routes
2322

src/bin/server.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ use cargo_registry::{boot, build_handler, env, git, App, Config, Env};
44
use std::{
55
env,
66
fs::{self, File},
7-
sync::{mpsc::channel, Arc},
7+
sync::Arc,
88
};
99

10-
use civet::Server;
10+
use conduit_hyper::Service;
1111

1212
fn main() {
1313
// Initialize logging
@@ -63,9 +63,8 @@ fn main() {
6363
} else {
6464
50
6565
};
66-
let mut cfg = civet::Config::new();
67-
cfg.port(port).threads(threads).keep_alive(true);
68-
let _a = Server::start(cfg, app);
66+
let addr = ([127, 0, 0, 1], port).into();
67+
let server = Service::new(app, threads);
6968

7069
println!("listening on port {}", port);
7170

@@ -76,6 +75,5 @@ fn main() {
7675
}
7776

7877
// TODO: handle a graceful shutdown by just waiting for a SIG{INT,TERM}
79-
let (_tx, rx) = channel::<()>();
80-
rx.recv().unwrap();
78+
server.run(addr);
8179
}

src/old_semver/Cargo.toml

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/old_semver/src/lib.rs

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/util/request_proxy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::{io::Read, net::SocketAddr};
22

33
use conduit::Request;
4-
use old_semver::semver;
4+
use conduit_hyper::semver;
55

66
// Can't derive Debug because of Request.
77
#[allow(missing_debug_implementations)]

0 commit comments

Comments
 (0)