Skip to content

Commit

Permalink
Depend on some crate directly
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto committed Mar 11, 2024
1 parent 3ce41f0 commit b152b76
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ appveyor = { repository = "lipanski/mockito", branch = "master", service = "gith

[dependencies]
assert-json-diff = "2.0"
bytes = "1"
colored = { version = "2.0", optional = true }
futures-core = "0.3"
http = "0.2"
hyper = { version = "0.14", features = ["http1", "http2", "server", "stream"] }
log = "0.4"
rand = "0.8"
Expand Down
2 changes: 1 addition & 1 deletion src/matcher.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use assert_json_diff::{assert_json_matches_no_panic, CompareMode};
use hyper::header::HeaderValue;
use http::header::HeaderValue;
use regex::Regex;
use std::collections::HashMap;
use std::convert::From;
Expand Down
4 changes: 1 addition & 3 deletions src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ use crate::server::RemoteMock;
use crate::server::State;
use crate::Request;
use crate::{Error, ErrorKind};
use hyper::header::HeaderName;
use hyper::HeaderMap;
use hyper::StatusCode;
use http::{HeaderMap, HeaderName, StatusCode};
use rand::distributions::Alphanumeric;
use rand::{thread_rng, Rng};
use std::convert::Into;
Expand Down
11 changes: 5 additions & 6 deletions src/request.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
use crate::{Error, ErrorKind};
use bytes::Buf;
use http::header::{AsHeaderName, HeaderValue};
use http::Request as HttpRequest;
use hyper::body;
use hyper::body::Buf;
use hyper::header::AsHeaderName;
use hyper::header::HeaderValue;
use hyper::Body as HyperBody;
use hyper::Request as HyperRequest;

///
/// Stores a HTTP request
///
#[derive(Debug)]
pub struct Request {
inner: HyperRequest<HyperBody>,
inner: HttpRequest<HyperBody>,
body: Option<Vec<u8>>,
}

impl Request {
pub(crate) fn new(request: HyperRequest<HyperBody>) -> Self {
pub(crate) fn new(request: HttpRequest<HyperBody>) -> Self {
Request {
inner: request,
body: None,
Expand Down
3 changes: 1 addition & 2 deletions src/response.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use crate::error::Error;
use crate::Request;
use futures_core::stream::Stream;
use hyper::HeaderMap;
use hyper::StatusCode;
use http::{HeaderMap, StatusCode};
use std::fmt;
use std::io;
use std::sync::Arc;
Expand Down
7 changes: 4 additions & 3 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ use crate::request::Request;
use crate::response::{Body as ResponseBody, ChunkedStream};
use crate::ServerGuard;
use crate::{Error, ErrorKind, Matcher, Mock};
use http::{Request as HttpRequest, Response, StatusCode};
use hyper::server::conn::Http;
use hyper::service::service_fn;
use hyper::{Body, Request as HyperRequest, Response, StatusCode};
use hyper::Body;
use std::default::Default;
use std::fmt;
use std::net::{IpAddr, SocketAddr};
Expand Down Expand Up @@ -355,7 +356,7 @@ impl Server {
let _ = Http::new()
.serve_connection(
stream,
service_fn(move |request: HyperRequest<Body>| {
service_fn(move |request: HttpRequest<Body>| {
handle_request(request, mutex.clone())
}),
)
Expand Down Expand Up @@ -442,7 +443,7 @@ impl fmt::Display for Server {
}

async fn handle_request(
hyper_request: HyperRequest<Body>,
hyper_request: HttpRequest<Body>,
state: Arc<RwLock<State>>,
) -> Result<Response<Body>, Error> {
let mut request = Request::new(hyper_request);
Expand Down

0 comments on commit b152b76

Please sign in to comment.