gravity
gravity copied to clipboard
Http support
Just want to say I've had a lot of fun with gravity 😄
I created an issue #280 about adding http support. I'm still unsure if this is wanted at this point in the project. With feedback, I'd be happy to refactor this janky pr a bit and implement the rest for an mvp. Or you can tell me my code sucks and to go home.
I've been testing using a basic flask server and the following gravity script:
func main() {
var get_tests = [
[
"host": "https://reddit.com"
],
[
"host": "https://api.github.com",
"path": "/users/jamesalbert"
],
[
"host": "https://httpbin.org",
"path": "/get"
]
]
get_tests.loop(func (request) {
var resp = Http.get(request)
System.print("=== " + resp.Hostname)
System.print(resp)
})
var post_tests = [
[
"host": "https://httpbin.org/post",
"path": "/post",
"data": [
"pet": "cat"
]
]
]
post_tests.loop(func (request) {
var resp = Http.post(request)
System.print("=== " + resp.Hostname)
System.print(resp)
})
}
Thanks @jamesalbert for your work on Gravity!
Awesome @marcobambini I'll try and tackle these after work. Np, it's a nice little language, I like the style
Thanks @jamesalbert and please note that a unit test would be recommended.
@marcobambini I figured an http client without ssl support is pretty useless. I added openssl support and tried to make it as non-dependent as possible. If the user doesn't have openssl, they can set the optional make parameter OPENSSL_ENABLED to false. I only have my macbook (with openssl) to my disposal, so I added some docker to build and run the example (1 container with openssl, 1 without). All 3 environments are building for me, but I'm sure there's more we can do.
Let me know what you think. You can run the examples in docker with make docker
@jamesalbert I apologize for taking so long in reviewing your pull request but I made a lot of refactoring for optional classes. Can you please remove the files: gravity_visualstudio/gravity.vcxproj gravity_visualstudio/gravity.vcxproj.filters so I can fix the remaining conflicts and merge your pull request? Thanks a lot.
@marcobambini not sure if this is still possible to be revisited. would it be possible to carry this work through with this pr's changes, if it currently isnt in the main release?