mirror of
https://github.com/robertwayne/axum-htmx
synced 2024-11-26 05:09:35 +01:00
Remove unnecessary .to_string() call when creating a header from JSON data
The original version would double quote values, resulting in serde_json inserting escape characters into the final string value, which prevented the header from being parsed by htmx properly.
This commit is contained in:
parent
81b9c548b3
commit
a1bac4b30e
1 changed files with 3 additions and 2 deletions
|
@ -193,8 +193,9 @@ pub(crate) fn events_to_header_value(events: Vec<HxEvent>) -> Result<HeaderValue
|
|||
// encoded.
|
||||
let header_value = events
|
||||
.into_iter()
|
||||
.map(|e| (e.name, e.data.map(|d| d.to_string()).unwrap_or_default()))
|
||||
.collect::<HashMap<_, _>>();
|
||||
.map(|e| (e.name, e.data.unwrap_or_default()))
|
||||
.collect::<HashMap<String, Value>>();
|
||||
|
||||
serde_json::to_string(&header_value)?
|
||||
} else {
|
||||
// no event contains data, the event names can be put in the header
|
||||
|
|
Loading…
Reference in a new issue