Skip to content

Commit 625636a

Browse files
committed
hyperapp: remove set_response_body
1 parent ac4cfd3 commit 625636a

File tree

2 files changed

+2
-42
lines changed

2 files changed

+2
-42
lines changed

src/http/server.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,16 +1080,6 @@ impl HttpServer {
10801080

10811081
/// Send an HTTP response to an incoming HTTP request ([`HttpServerRequest::Http`]).
10821082
pub fn send_response(status: StatusCode, headers: Option<HashMap<String, String>>, body: Vec<u8>) {
1083-
// Check if there's a manual body override in the HTTP context
1084-
let final_body = crate::hyperapp::APP_HELPERS.with(|helpers| {
1085-
helpers
1086-
.borrow()
1087-
.current_http_context
1088-
.as_ref()
1089-
.and_then(|ctx| ctx.response_body.clone())
1090-
.unwrap_or(body) // Use override if present, otherwise use the parameter
1091-
});
1092-
10931083
KiResponse::new()
10941084
.body(
10951085
serde_json::to_vec(&HttpResponse {
@@ -1098,7 +1088,7 @@ pub fn send_response(status: StatusCode, headers: Option<HashMap<String, String>
10981088
})
10991089
.unwrap(),
11001090
)
1101-
.blob_bytes(final_body)
1091+
.blob_bytes(body)
11021092
.send()
11031093
.unwrap()
11041094
}

src/hyperapp.rs

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ pub struct HttpRequestContext {
3838
pub request: IncomingHttpRequest,
3939
pub response_headers: HashMap<String, String>,
4040
pub response_status: http::StatusCode,
41-
pub response_body: Option<Vec<u8>>,
4241
}
4342

4443
pub struct AppContext {
@@ -139,15 +138,6 @@ pub fn set_response_status(status: http::StatusCode) {
139138
})
140139
}
141140

142-
// Set the HTTP response body directly (bypasses Result serialization)
143-
pub fn set_response_body(body: Vec<u8>) {
144-
APP_HELPERS.with(|helpers| {
145-
if let Some(ctx) = &mut helpers.borrow_mut().current_http_context {
146-
ctx.response_body = Some(body);
147-
}
148-
})
149-
}
150-
151141
pub fn clear_http_request_context() {
152142
APP_HELPERS.with(|helpers| {
153143
helpers.borrow_mut().current_http_context = None;
@@ -166,30 +156,10 @@ pub fn source() -> Address {
166156
})
167157
}
168158

169-
/// Get query parameters from the current HTTP request path (manually parsed)
170-
/// Returns None if not in an HTTP context or no query parameters present
171-
/// NOTE: This manually parses the path string. For pre-parsed params, use get_parsed_query_params()
172-
pub fn get_query_params() -> Option<HashMap<String, String>> {
173-
get_path().map(|path| {
174-
let mut params = HashMap::new();
175-
if let Some(query_start) = path.find('?') {
176-
let query = &path[query_start + 1..];
177-
for pair in query.split('&') {
178-
if let Some(eq_pos) = pair.find('=') {
179-
let key = pair[..eq_pos].to_string();
180-
let value = pair[eq_pos + 1..].to_string();
181-
params.insert(key, value);
182-
}
183-
}
184-
}
185-
params
186-
})
187-
}
188-
189159
/// Get the pre-parsed query parameters from the current HTTP request
190160
/// Returns None if not in an HTTP context
191161
/// This accesses the query_params field that Hyperware already parsed (includes URL decoding)
192-
pub fn get_parsed_query_params() -> Option<HashMap<String, String>> {
162+
pub fn get_query_params() -> Option<HashMap<String, String>> {
193163
APP_HELPERS.with(|helpers| {
194164
helpers
195165
.borrow()

0 commit comments

Comments
 (0)