Mar 22
Brad Lindsay [ANN] Lasso-HTTP Production Ready
Mar 22, 2014; 10:16
Brad Lindsay
[ANN] Lasso-HTTP Production Ready
I mentioned a while back a small library I was working on to replace
[include_url] when it came to issuing requests to HTTP APIs. I have had
a lot of great feedback from various people (thank you all - especially
Jono), and it is now ready for production use.
You can find the code on Github here:
https://github.com/bfad/Lasso-HTTP
It consists of two types, one that allows you to build a request like this:
local(req) = http_request("http://example.com/foo")
#req->headers = (:'Content-Type'='application/json')
#req->postParams = json_serialize(map('moose'='hair'))
#req->timeout = 300
Or, you can create a request all in one method call:
local(req) = http_request(
"http://example.com/foo",
-postParams = (:'name'='Rhino'),
-reqMethod = `PUT`
)
Once you have a request built, you can get the result back in an
http_response type and easily inspect the various parts:
// If the request doesn't return with a 200 status code, error with the
status and message
// Otherwise show the body of the HTTP response
local(resp) = #req->response
fail_if(#resp->getStatus != 200, #resp->statusCode, #resp->statusMsg)
#resp->bodyString
More often then not, this is probably the form your code will take:
local(resp) = http_request(
"http://example.com/foo",
-postParams = (:'name'='Rhino'),
-reqMethod = `PUT`
)->response
match(#resp->statusCode) => {
case(400)
content_body = 'Malformed Request'
case(401)
content_body = 'Credentials Expired'
case(200)
content_body = #resp->bodyString
case
fail(#resp->statusCode, #resp->statusMsg)
}
Once again, the project is hosted on Github:
https://github.com/bfad/Lasso-HTTP
Please use Github's Issues to submit feature requests or bug reports.
Thanks,
Brad
#lasso9 #curl #restapi
#############################################################
This message is sent to you because you are subscribed to
the mailing list Lasso Lasso@lists.lassosoft.com
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <Lasso-unsubscribe@lists.lassosoft.com>
Send administrative queries to <Lasso-request@lists.lassosoft.com>
Mar 22
Bil Corry Re: [ANN] Lasso-HTTP Production Ready
Mar 22, 2014; 17:27
Bil Corry
Re: [ANN] Lasso-HTTP Production Ready
Mar 22
deco rior Re: [ANN] Lasso-HTTP Production Ready
Mar 22, 2014; 11:33
deco rior
Re: [ANN] Lasso-HTTP Production Ready
Mar 23
Jolle Carlestam Re: [ANN] Lasso-HTTP Production Ready
Mar 23, 2014; 07:17
Jolle Carlestam
Re: [ANN] Lasso-HTTP Production Ready
Mar 22
Jonathan Guthrie Re: [ANN] Lasso-HTTP Production Ready
Mar 22, 2014; 23:38
Jonathan Guthrie
Re: [ANN] Lasso-HTTP Production Ready
Mar 23
deco rior Re: [ANN] Lasso-HTTP Production Ready
Mar 23, 2014; 08:22
deco rior
Re: [ANN] Lasso-HTTP Production Ready
Mar 23
Brad Lindsay Re: [ANN] Lasso-HTTP Production Ready
Mar 23, 2014; 11:33
Brad Lindsay
Re: [ANN] Lasso-HTTP Production Ready
Mar 23
Brad Lindsay Re: [ANN] Lasso-HTTP Production Ready
Mar 23, 2014; 11:38
Brad Lindsay
Re: [ANN] Lasso-HTTP Production Ready
Mar 23
Brad Lindsay Re: [ANN] Lasso-HTTP Production Ready
Mar 23, 2014; 11:55
Brad Lindsay
Re: [ANN] Lasso-HTTP Production Ready
Mar 23
deco rior Re: [ANN] Lasso-HTTP Production Ready
Mar 23, 2014; 11:18
deco rior
Re: [ANN] Lasso-HTTP Production Ready
Mar 23
deco rior Re: [ANN] Lasso-HTTP Production Ready
Mar 23, 2014; 11:26
deco rior
Re: [ANN] Lasso-HTTP Production Ready