resty | Simple HTTP and REST client library for Go | HTTP library

 by   go-resty Go Version: v2.7.0 License: MIT

kandi X-RAY | resty Summary

kandi X-RAY | resty Summary

resty is a Go library typically used in Networking, HTTP applications. resty has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.

Simple HTTP and REST client library for Go (inspired by Ruby rest-client). Features section describes in detail about Resty capabilities.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              resty has a medium active ecosystem.
              It has 7925 star(s) with 613 fork(s). There are 92 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 92 open issues and 307 have been closed. On average issues are closed in 75 days. There are 12 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of resty is v2.7.0

            kandi-Quality Quality

              resty has no bugs reported.

            kandi-Security Security

              resty has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              resty is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              resty releases are available to install and integrate.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of resty
            Get all kandi verified functions for this library.

            resty Key Features

            No Key Features are available at this moment for resty.

            resty Examples and Code Snippets

            No Code Snippets are available at this moment for resty.

            Community Discussions

            QUESTION

            How to make my redis connection Singleton in Lua?
            Asked 2021-May-09 at 07:40

            I am trying to handle incoming HTTP requests by Nginx and Lua. I need to read a blue from Redis in each request and currently, I open a Redis connection in every request by this code:

            ...

            ANSWER

            Answered 2021-May-09 at 07:40

            It is impossible to share a cosocket object (and, therefore, a redis object, check this answer for details) between different requests:

            The cosocket object created by this API function has exactly the same lifetime as the Lua handler creating it. So never pass the cosocket object to any other Lua handler (including ngx.timer callback functions) and never share the cosocket object between different Nginx requests.

            However, nginx/ngx_lua uses a connection pool internally:

            Before actually resolving the host name and connecting to the remote backend, this method will always look up the connection pool for matched idle connections created by previous calls of this method

            That being said, you just need to use sock:setkeepalive() instead of sock:close() for persistent connections. The redis object interface has a corresponding method: red:set_keepalive().

            You'll still need to create a redis object on a per request basis, but this will help to avoid a connection overhead.

            Source https://stackoverflow.com/questions/67455065

            QUESTION

            why Nginx container cannot resolve redis container by name?
            Asked 2021-May-02 at 12:26

            I have a docker-compose that run two containers, one an Nginx with Lua-module and another is a simple Redis, here is the docker-compose file:

            ...

            ANSWER

            Answered 2021-May-02 at 12:26

            I found the solution but I did not the root cause of problem:

            I changed my Nginx-Lua image from danday74/nginx-lua to fabiocicerchia/nginx-lua, and It worked like a charm. the first one was created on Nginx version 1.16 and the last one was created by Nginx 1.19.

            Source https://stackoverflow.com/questions/67318078

            QUESTION

            Symbol not found: OpenSSL_version_num
            Asked 2021-Apr-24 at 23:03

            I am trying to create a kong plugin. It works great when running as part of kong server but when I am trying to write some unit tests with busted, resty.openssl.digest func load fails. More specifically while loading the version.lua

            I am not sure what exactly I am missing. Maybe some link which is supposed to link openSSL's C functions to lua.

            Here is a minimal snippet to reproduce the problem.

            ...

            ANSWER

            Answered 2021-Apr-24 at 23:03

            You should ffi.load your .so library before using functions from it.

            Source https://stackoverflow.com/questions/67244476

            QUESTION

            Keycloack: After logout, the access token can still be used
            Asked 2021-Apr-22 at 13:49

            I have an nginx/openresty client to a keycloack server for authorization using openid. I am using lua-resty-openidc to allow access to services behind the proxy.

            The user can access his profile at https:///auth/realms//account and logout through https:///auth/realms//protocol/openid-connect/logout

            The problem is that, even after logout, the user can still access the services behind the server, basically it seems the token he gets from keycloak is still valid or something.... This is also a behaviour that has been observed by other users, see for example this question on how to logout from keycloak the comments from ch271828n

            How can I ensure that after logout the user will no longer be able to get access until he logs in anew?

            ...

            ANSWER

            Answered 2021-Apr-22 at 13:49

            I had to check the lua source code, but I think I have figured the logout behaviour out: Lua-resty-openidc establishes sessions, and they are terminated when a specific url access is detected (it is controlled by opts.logout_path which we will need to be set to an address in the path of service, e.g. .../service/logout)

            In essence, there are two urls that need to be hit, one for keycloack logout, and one for openresty session logout. Accessing the keycloack logout url https:///auth/realms//protocol/openid-connect/logout is done by lua after we access the opts.logout_path at https:///service/logout

            So after setting up everything correctly, all we have to do to logout is hit https:///service/logout. This will destroy the session and log us out.

            I think we need to set opts.revoke_tokens_on_logout to true, Also note that from my experiments, for some reason, setting up a redirect_after_logout_uri may result in the user not signing out due to redirections.

            Here is an example of what we need to have for nginx.conf to make this work....

            Source https://stackoverflow.com/questions/67194730

            QUESTION

            OpenResty - No response when making a http call with lua
            Asked 2021-Mar-24 at 19:00

            when making a request to an url from within my nginx the response of this request is always not present. It seems that the request is not sended.

            This is my nginx.conf

            ...

            ANSWER

            Answered 2021-Mar-24 at 19:00

            no resolver defined to resolve "www.google.de"

            You need to configure the resolver:

            https://github.com/openresty/lua-nginx-module#tcpsockconnect

            In case of domain names, this method will use Nginx core's dynamic resolver to parse the domain name without blocking and it is required to configure the resolver directive in the nginx.conf file like this:

            Source https://stackoverflow.com/questions/66784758

            QUESTION

            why doesn't resty.redis work with the ngx.timer?
            Asked 2021-Jan-26 at 18:06

            I've asked here but thought I'd post on SO as well:

            given this code:

            ...

            ANSWER

            Answered 2021-Jan-26 at 18:06

            There are two errors in your code.

            1. It is not possible to pass the cosocket object between Lua handlers (emphasis added by me):

              The cosocket object created by this API function has exactly the same lifetime as the Lua handler creating it. So never pass the cosocket object to any other Lua handler (including ngx.timer callback functions) and never share the cosocket object between different Nginx requests.

              https://github.com/openresty/lua-nginx-module#ngxsockettcp

              In your case, the reference to the cosocket object is stored in the client table (client._sock).

            2. ngx.print/ngx.say are not available in the ngx.timer.* context.

              https://github.com/openresty/lua-nginx-module#ngxsay (check the context: section).

              You can use ngx.log instead (it writes to nginx log, set error_log stderr debug; in nginx.conf to print logs to stderr).

            The following code works as expected:

            Source https://stackoverflow.com/questions/65895230

            QUESTION

            How do you create an automation API POST test request using Resty
            Asked 2020-Dec-06 at 16:06

            I have managed to successfully setup my API automation tests in Go using Resty and execute a GET request.

            I am however struggling to get a POST API test to return a 200 instead I receive a 400 error message. I'm not sure what I'm doing wrong.

            Please see my code below. (The POST request works in Postman by the way!)

            ...

            ANSWER

            Answered 2020-Dec-06 at 14:33

            You need to add a Content-Type. This should work:

            Source https://stackoverflow.com/questions/65169149

            QUESTION

            Nginx lua openresty variable scope
            Asked 2020-Dec-01 at 14:52

            Here is working example of openresty nginx.conf file. In this example I make request to redis multiple times. As you can see I request data from redis first to check if domain can get SSL then again to get what backend to proxy request to, and then I've added S3 proxy and I would need to request data from redis again. I'm new to OpenResty and Lua and I wonder if it is possible to fetch data from redis once and use it multiple times across the script?

            ...

            ANSWER

            Answered 2020-Dec-01 at 14:52

            OpenResty run Lua hooks in a sandbox, so one cannot use global variables to share data.

            You shall use Data Sharing within an Nginx Worker It is usual practice to cache anything on Lua module level, possibly with some reasonable expiration period if data stored in Redis may be changed.

            BTW - don't use XXX_by_lua directives - you should take care about nginx escaping rules, use XXX_by_lua_block.

            Additional example:

            Source https://stackoverflow.com/questions/65048400

            QUESTION

            OpenResty disable TLS 1.0 and TLS 1.1 in auto genereated certs
            Asked 2020-Nov-05 at 00:55

            Lately i was playing with openresty and lua-resty-auto-ssl and can't find how to disable TLS 1.0 and TLS 1.1, (and add ciphers). I just read whole internet twice, and found nothing. In nginx is simple one line ssl_protocols TLSv1.3 TLSv1.2; but its not affecting lua-resty-auto-ssl i have no idea how to do it, would be nice if someone could shed some light on this topic.

            ...

            ANSWER

            Answered 2020-Nov-03 at 18:45

            I just found answer here:

            lua_ssl_protocols TLSv1.2 TLSv1.3;

            Source https://stackoverflow.com/questions/63145575

            QUESTION

            How to sign a JWT with a private key in LUA
            Asked 2020-Oct-26 at 09:30

            I'm using the kubernetes nginx ingress controller

            ...

            ANSWER

            Answered 2020-Oct-26 at 09:30

            I finally ended with creating a new method in openidc.lua, which apparently contains all necessary stuff to call jwt.lua. Not sure what's missing from calling it directly from nginx.tmpl though.

            Source https://stackoverflow.com/questions/64501635

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install resty

            You can download it from GitHub.

            Support

            I would welcome your contribution! If you find any improvement or issue you want to fix, feel free to send a pull request, I like pull requests that include test cases for fix/enhancement. I have done my best to bring pretty good code coverage. Feel free to write tests. BTW, I'd like to know what you think about Resty. Kindly open an issue or send me an email; it'd mean a lot to me.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries

            Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link