I want to write an API client app for our REST API. The app
serving the API publicizes it over different subdomains for
different clients, i.e.:
clientA.myapp.org/api/people
clientB.myapp.org/api/people
The client app must be able to query any client depending on the
user logged in to the client app.
The set of possible clients is not static and can change any
time.
ActiveResource::Base.site is usually set at app startup time,
which makes no sense for me, because I don't know to which client
the first user accessing my client app belongs to yet.
Resetting site with every request is not a solution, because I
think it's not thread safe, since site is a class variable and
shared across all parallel requests.
The solution is imho to make site not a value, but either a
function or an object that is capable of calculating the site at
runtime.
I hope this makes any sense to you.