Skip to content

Commit

Permalink
[wip] pass request object along with the response body
Browse files Browse the repository at this point in the history
  • Loading branch information
VishnuSanal committed Aug 26, 2024
1 parent 15728ed commit 7429479
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions robyn/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ def _format_response(
headers=headers,
description=str(res).encode("utf-8"),
)

print("vishnu: ", response.request) # always None

return response

def add_route(
Expand Down
5 changes: 2 additions & 3 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,10 @@ async fn index(
Response::not_found(None)
};

println!("OG Response : {:?}", response);
println!("Request : {:?}", request);
debug!("OG Response : {:?}", response);

response.headers.extend(&global_response_headers);
response.request = Some(request); // FIXME: 'builtins.Response' object has no attribute 'request'
response.request = Some(request);

debug!("Extended Response : {:?}", response);

Expand Down
6 changes: 6 additions & 0 deletions src/types/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ impl ToPyObject for Request {
}
}

impl IntoPy<PyObject> for Request {
fn into_py(self, py: Python<'_>) -> PyObject {
self.to_object(py)
}
}

async fn handle_multipart(
mut payload: Multipart,
files: &mut HashMap<String, Vec<u8>>,
Expand Down
1 change: 1 addition & 0 deletions src/types/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ pub struct PyResponse {
pub description: Py<PyAny>,
#[pyo3(get)]
pub file_path: Option<String>,
#[pyo3(get, set)]
pub request: Option<Request>
}

Expand Down

0 comments on commit 7429479

Please sign in to comment.