summaryrefslogtreecommitdiff
path: root/desk/lib/shim.hoon
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-09-17 21:45:18 +0700
committerpolwex <polwex@sortug.com>2025-09-17 21:45:18 +0700
commit985fa2f7c99832cdf3c3351d2273c8fd05402b78 (patch)
treebc727486a89ad05e588754f8de8b1096400a3d31 /desk/lib/shim.hoon
parentf0df4c7297a05bd592d8717b8997284c80fd0500 (diff)
basic comms working
Diffstat (limited to 'desk/lib/shim.hoon')
-rw-r--r--desk/lib/shim.hoon10
1 files changed, 9 insertions, 1 deletions
diff --git a/desk/lib/shim.hoon b/desk/lib/shim.hoon
index f2e0b8a..1b78f0a 100644
--- a/desk/lib/shim.hoon
+++ b/desk/lib/shim.hoon
@@ -13,7 +13,9 @@
++ parse-body |= jstring=@t
=/ ures (de:json:html jstring)
?~ ures ~
- (shim-res:de:js u.ures)
+ =/ ur (shim-res:de:js u.ures)
+ ?~ ur ~& >>> shim-msg-parsing-failed=jstring ~
+ ur
:: __
++ get-req |= fs=(list filter:nsur)
^- [bulk-req:shim:nsur _state]
@@ -74,8 +76,11 @@
|= req=bulk-req:shim:nsur ^- card:agent:gall
=/ req-body (bulk-req:en:js req)
:: ~& shim-req-json=(en:json:html req-body)
+ =/ host .^(hart:eyre %e /(scot %p our.bowl)/host/(scot %da now.bowl))
+ =/ origin %- crip (head:en-purl:html host)
=/ headers :~
[key='content-type' value='application/json']
+ [key='origin' value=origin]
==
=/ =request:http [%'POST' url:shim:nsur headers `(json-body:web req-body)]
=/ pat /shim
@@ -86,8 +91,11 @@
^- card:agent:gall
=/ req-body (http-req:en:js req)
:: ~& shim-req-json=(en:json:html req-body)
+ =/ host .^(hart:eyre %e /(scot %p our.bowl)/host/(scot %da now.bowl))
+ =/ origin %- crip (head:en-purl:html host)
=/ headers :~
[key='content-type' value='application/json']
+ [key='origin' value=origin]
==
=/ =request:http [%'POST' url:shim:nsur headers `(json-body:web req-body)]
[%pass /http/[sub-id.req] %arvo %k %fard dap.bowl %fetch %noun !>(request)]