Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DISCUSS]: Use luasocket lib instead of curl in "bin/apisix" #2818

Closed
starsz opened this issue Nov 22, 2020 · 12 comments · Fixed by #2965
Closed

[DISCUSS]: Use luasocket lib instead of curl in "bin/apisix" #2818

starsz opened this issue Nov 22, 2020 · 12 comments · Fixed by #2965

Comments

@starsz
Copy link
Contributor

starsz commented Nov 22, 2020

Hi, I advise using luasocket lib instead of curl in "bin/apisix".

Although, it's very convenient to get HTTP responses by using "io.open" and "curl".
But, I think it's not an elegant way and has some limitations. Such as can't distinguish error info between Connection refused and empty response.

So I think we can use luasocket lib and create a common function in "cli/util.lua", so that we can deal with some HTTP request better in "bin/apisix".

releated: #2718

@spacewander
Copy link
Member

Do you mean writing a new HTTP client based on luasocket? Since lua-resty-http can't be used without ngx.

@tokers
Copy link
Contributor

tokers commented Nov 23, 2020

Do you mean writing a new HTTP client based on luasocket? Since lua-resty-http can't be used without ngx.

The luasocket lib already has a HTTP client implementation.

@starsz
Copy link
Contributor Author

starsz commented Nov 23, 2020

Hi, @spacewander @tokers, Yeah, luasocket had an HTTP client implementation already.
See: doc
So, I want to use luasocket lib instead of curl in "bin/apisix".

@tokers
Copy link
Contributor

tokers commented Nov 23, 2020

But i'm not sure whether it's built in? Or users have to install it before they can use bin/apisix.

@starsz
Copy link
Contributor Author

starsz commented Nov 23, 2020

But i'm not sure whether it's built in? Or users have to install it before they can use bin/apisix.

Users need to do make deps before they use bin/apisix. So I think it can be solved.

@tokers
Copy link
Contributor

tokers commented Nov 23, 2020

But i'm not sure whether it's built in? Or users have to install it before they can use bin/apisix.

Users need to do make deps before they use bin/apisix. So I think it can be solved.

OK, that's good.

@membphis
Copy link
Member

We can make a try.

Need to pay attention to the use of different systems(ubuntu, centos and mac os), whether there are compatibility issues.

@moonming
Copy link
Member

Can we specify the path of openresty to solve this problem? So we can use lua-resty-http.

@membphis
Copy link
Member

Do you mean to run the CLI in fake openresty ENV? Is it the same as the "resty" command?

@moonming
Copy link
Member

moonming commented Nov 23, 2020 via email

@spacewander
Copy link
Member

There are some limitation in resty, for instance, access environment variables.

@starsz
Copy link
Contributor Author

starsz commented Nov 24, 2020

Hi, @moonming, I think there is no need to use lua-resty-http.
In CLI, we don't care about non-blocking, and luasocket is also easy to use now.

What's your opinion about using lua-resty-http.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants