aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTeddy Wing2020-06-23 02:25:39 +0200
committerTeddy Wing2020-06-23 02:25:39 +0200
commit31c78b8655ed464c0575742b0f3f6c5daa179f97 (patch)
treeef0fb91baa9aa52d8c117213a0db385b84b40893 /src
parent80c075cbfa0a311f7cd0d156d66e424a6ef3d1f5 (diff)
downloadfastcgi-conduit-31c78b8655ed464c0575742b0f3f6c5daa179f97.tar.bz2
Start conversion from `fastcgi::Request` to `http::Request`
Currently only converts the HTTP method and URI. Still need to convert HTTP headers.
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 9b87edf..88752fb 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -32,3 +32,27 @@ where F: Fn(Request<()>) -> Response<T> + Send + Sync + 'static
.unwrap_or(());
});
}
+
+trait From<T>: Sized {
+ fn from(_: T) -> Self;
+}
+
+impl From<fastcgi::Request> for http::request::Builder {
+ fn from(request: fastcgi::Request) -> Self {
+ let method = request.param("REQUEST_METHOD")
+ .unwrap_or("".to_owned());
+
+ let uri = format!(
+ "{}://{}{}",
+ request.param("REQUEST_SCHEME").unwrap_or("".to_owned()),
+ request.param("HTTP_HOST").unwrap_or("".to_owned()),
+ request.param("REQUEST_URI").unwrap_or("".to_owned()),
+ );
+
+ return http::request::Builder::new()
+ .method(&*method)
+ .uri(&uri)
+
+ // HTTP_* params become headers
+ }
+}