diff options
| author | Teddy Wing | 2020-06-23 02:25:39 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2020-06-23 02:25:39 +0200 | 
| commit | 31c78b8655ed464c0575742b0f3f6c5daa179f97 (patch) | |
| tree | ef0fb91baa9aa52d8c117213a0db385b84b40893 /src | |
| parent | 80c075cbfa0a311f7cd0d156d66e424a6ef3d1f5 (diff) | |
| download | fastcgi-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.rs | 24 | 
1 files changed, 24 insertions, 0 deletions
| @@ -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 +    } +} | 
