B4J Question jServer REST API Design

alwaysbusy

Expert
Licensed User
Longtime User
This is more like a design/performance question. Suppose one has a REST API with several (hundereds?) of paths (don't make sense here, but for arguments sake):

B4X:
/v1/pets/add
/v1/pets/get
/v1/pets/getoftype
/v1/pets/getwithforlegs
...

Do you guys make one handler /v1/pets/ and then a 'select case' of the sub path, or a handler for each sub path?

Would there be a performance difference?

The second option (handler for each sub path) looks like overkill to me, especially if hundereds of them are involved.
 

Cableguy

Expert
Licensed User
Longtime User
O guess it depends on (at least) one major prerogative...
Are these handlers known from the start of the app development or are they added as needed?
In the first case, a developers would be as at ease with a case select ensemble as with individual handlers.
In the second case, although individual handlers may seem overkill, they make the app much more scalable and versatile yet code wise very manageable.
If a particular handlers needs tweaking or simply removed, it' much more simple to do it with the second approach
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
You could do simple tests, by creating empty handlers that just log a meaningful phrase and another with the same amount of cases and log timings to see if there is any significant difference...
Yet dev wise, there will be a lot more work and organisational thinking needed with a case select option

(I still can't get over the fact that I'm actually trying to advise @alwaysbusy on how to do is work... I must be crazy!!)
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
After that I logged into a server at work
Looks like your server has good protection! It is made by an ethical hacker from Belgium who will reveal how he does it in a couple of days. His main point is showing everyone that those 'fun question games' on facebook aren't as innocent as they seem.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
I'm using my work phone where I also have my Google account and Facebook account and trello...
And it didn't find my name.... maybe I don' have one (?)
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
lol, this is how he does it appearantly (from the source code of the website):

B4X:
window.fbAsyncInit = function() {
        FB.init({
          appId      : '803xxxxxxxxxx',
          xfbml      : true,
          version    : 'v2.12'
        });
        FB.getLoginStatus(function(response) {
          if (response.status === 'connected') {
            loggedIn = true;
            var uid = response.authResponse.userID;
            var accessToken = response.authResponse.accessToken;
          } else if (response.status === 'not_authorized') {
            loggedIn = true;
          } else {
            // the user isn't logged in to Facebook.
          }
        });
        FB.AppEvents.logPageView();
      };
 
Upvote 0

udg

Expert
Licensed User
Longtime User
lol, this is how he does it appearantly
Suspecting a trick like that, before taking the "test" I restarted my PC, cleaned up any cache and started Firefox directly with that URL.
It couldn't reveal my identity..
BTW, even if it were based on some huge "social" db it would have had low to no chance with me since I am deeply "asocial"..eheh
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
It couldn't guess mine, it kept guessing German sounding names lol.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Upvote 0
Top