Builder pattern allow
- to do one line of code to configure the request
- to have code completion for request configuration features (instead of knowning by heart the property names of
4D.HTTPRequest
)
var $client : cs.HTTPClient
$client:=cs.HTTPClient.new()
$client.get("https://httpbin.org/")\
.onTerminate(Formula(ALERT(JSON Stringify($1.response))))\
.build()\
.wait()
or just getting request without waiting synchronously
var $request: 4D.HTTPREquest
$request:=$client.get("https://httpbin.org/")\
.onTerminate(Formula(ALERT(JSON Stringify($1.response))))\
.build()
Class constructor
This.client:=cs.HTTPClient.new()
Function receiveHttpBinData($response : Object; $event : Object)
// ...
Function run()
$client.get("https://httpbin.org/")\
.onTerminate(This.receiveHttpBinData)\
.build()\
.wait()
$client.request()\
.GET()\
.url("https://httpbin.org/")\
.appendHeader("Toto"; "Totovalue")\
.version(1)\
.onTerminate(Formula(ALERT(JSON Stringify($1.response))))\
.build()\
.wait()