rest-client / rest-client

Simple HTTP and REST client for Ruby, inspired by microframework syntax for specifying actions.

Home Page:https://rubydoc.info/github/rest-client/rest-client/master

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cover API/url in a class

hadmut opened this issue · comments

Would be nice to have class to cover the base URL to avoid having to repeat it.

E.g.
api=rest-client::API.new('https://some-example.com/some-rest-api')

api.get('/somefunction')
api.put('/another')

Which means parsing the URL for every single call? Would be poor programming.

Well, then maybe this issue should be handled by someone who knows the difference.

URLs are usually parsed by regular expressions, which are expensive in cpu time. If you do a string expansion and URL parsing for every single call (which could mean a million calls per day) you are wasting a lot of cpu time (any maybe battery power). If you put things into a class, it can have class variables to store the result of parsing. It's a matter of efficiency to store and reuse computation results instead of computing them every time from scratch.

And, btw., things are not similar just because the somewhat look similar.

This is a Ruby Gem and not a VSCode plugin. I'm not using VS at all.

This is to call REST APIs, and there are APIs you need to call a million times a day.

Is it, by any means, possible that you don't really understand what this is about?

And no, your proposals on beginner's level are no help at all.

I'm sorry, I've got myself confused with a different project with similar names.

I've deleted my comments as they don't help.