Note: The context of this question is javascript, however is generic enough to not tie it as just as a javascript question.
We have a javascript library that needs to send a request using http or https. In order to decide which protocol to use, our library calls a method that decides which protocol should we use. That method is declared in the 'user side of our library' (as a callback?).
For the moment we have named it as isConnectionSecure but we are not asking that but instead the question is more like:
Should we use the secure protocol?
The library is working somehow like:
OurSuperLibrary.api = {
isConnectionSecure: function () {
// Do your checks
return true;
}
}
var ourLibrary = new OurSuperLibrary();
// Internally, our library will call the previously declared method:
ourLibrary.doRequest();
Thanks.