Skip to content

Commit 3b752f2

Browse files
committed
feat(wasm): allow to serialize action from wasm
1 parent 2129f44 commit 3b752f2

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

pkg/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"Joel Wurtz <jwurtz@redirection.io>"
55
],
66
"description": "Redirection IO Library to handle matching rule, redirect and filtering headers and body.",
7-
"version": "3.0.0-dev",
7+
"version": "3.0.2-dev",
88
"license": "MIT",
99
"repository": {
1010
"type": "git",
11-
"url": "https://github.com/redirectionio/libredirectionio"
11+
"url": "git+https://github.com/redirectionio/libredirectionio.git"
1212
},
1313
"files": [
1414
"wasm/redirectionio.d.ts",

src/wasm_api.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,20 @@ impl Action {
150150
Action { action }
151151
}
152152

153+
pub fn serialize(&self) -> String {
154+
match &self.action {
155+
None => "".to_string(),
156+
Some(action) => match json_encode(action) {
157+
Err(err) => {
158+
log::error!("Unable to serialize to action: {}", err);
159+
160+
"".to_string()
161+
}
162+
Ok(action_serialized) => action_serialized,
163+
},
164+
}
165+
}
166+
153167
pub fn empty() -> Action {
154168
Action { action: None }
155169
}

0 commit comments

Comments
 (0)