Coder Social home page Coder Social logo

Resty client global variable about resty HOT 2 CLOSED

billypap1 avatar billypap1 commented on May 22, 2024
Resty client global variable

from resty.

Comments (2)

ahuigo avatar ahuigo commented on May 22, 2024

Global variables are not a good design and are prone to abuse.
Imagine a scenario :

  1. moduleA wants to set SetTimeout(5 * time. Second)
  2. moduleB wants to SetTimeout(500 * time. Second)
  3. moduleC wants to SkipSSL(true)
  4. moduleD wants to SkipSSL(false)

This can easily create conflicts, and very difficult to manage and troubleshoot bugs.

If you want to use a global variable, you can define this global variable within your app, limited to your own app

from resty.

jeevatkm avatar jeevatkm commented on May 22, 2024

@ahuigo Thanks for responding to a comment.

@billypap1 It is recommended to create a resty client per destination Host with respective settings for the usage.

client1 := resty.New().SetBaseURL("http://localohost1")
....

client2 := resty.New().SetBaseURL("http://localohost2")
...

from resty.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.