Skip to content

Commit

Permalink
Serialize ttl_status_map as object (#443)
Browse files Browse the repository at this point in the history
  • Loading branch information
caiges authored Feb 26, 2024
1 parent 053e1f8 commit 75a8408
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion worker/src/request_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::headers::Headers;
use crate::http::Method;

use js_sys::{self, Object};
use serde::Serialize;
use wasm_bindgen::{prelude::*, JsValue};

/// Optional options struct that contains settings to apply to the `Request`.
Expand Down Expand Up @@ -146,6 +147,7 @@ impl From<&CfProperties> for JsValue {
fn from(props: &CfProperties) -> Self {
let obj = js_sys::Object::new();
let defaults = CfProperties::default();
let serializer = serde_wasm_bindgen::Serializer::new().serialize_maps_as_objects(true);

set_prop(
&obj,
Expand Down Expand Up @@ -191,7 +193,7 @@ impl From<&CfProperties> for JsValue {
set_prop(
&obj,
&JsValue::from("cacheTtlByStatus"),
&serde_wasm_bindgen::to_value(&ttl_status_map).unwrap_or_default(),
&ttl_status_map.serialize(&serializer).unwrap_or_default(),
);

set_prop(
Expand Down

0 comments on commit 75a8408

Please sign in to comment.