aboutsummaryrefslogtreecommitdiff
path: root/examples/http/http.tm
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-04-04 17:06:09 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-04-04 17:06:09 -0400
commit0b8074154e2671691050bdb3bcb33245625a056c (patch)
tree1410e0c4e05c6372e876cd08f16d117e12868f41 /examples/http/http.tm
parentfadcb45baf1274e06cfe37b87655b9146aa52874 (diff)
First working compile of refactor to add explicit typing to declarations
and support untyped empty collections and `none`s
Diffstat (limited to 'examples/http/http.tm')
-rw-r--r--examples/http/http.tm6
1 files changed, 3 insertions, 3 deletions
diff --git a/examples/http/http.tm b/examples/http/http.tm
index 12203faf..ee1b8c75 100644
--- a/examples/http/http.tm
+++ b/examples/http/http.tm
@@ -7,8 +7,8 @@ struct HTTPResponse(code:Int, body:Text)
enum _Method(GET, POST, PUT, PATCH, DELETE)
-func _send(method:_Method, url:Text, data:Text?, headers=[:Text] -> HTTPResponse):
- chunks := @[:Text]
+func _send(method:_Method, url:Text, data:Text?, headers:[Text]=[] -> HTTPResponse):
+ chunks : @[Text] = @[]
save_chunk := func(chunk:CString, size:Int64, n:Int64):
chunks:insert(inline C:Text {
Text$format("%.*s", _$size*_$n, _$chunk)
@@ -81,7 +81,7 @@ func _send(method:_Method, url:Text, data:Text?, headers=[:Text] -> HTTPResponse
}
return HTTPResponse(Int(code), "":join(chunks))
-func get(url:Text, headers=[:Text] -> HTTPResponse):
+func get(url:Text, headers:[Text]=[] -> HTTPResponse):
return _send(GET, url, none, headers)
func post(url:Text, data="", headers=["Content-Type: application/json", "Accept: application/json"] -> HTTPResponse):