Allow relocation of Brooklyn REST API#11
Allow relocation of Brooklyn REST API#11asfgit merged 1 commit intoapache:masterfrom CMoH:relocate-rest-baseUrl
Conversation
src/main/webapp/assets/js/config.js
Outdated
| // var baseURL = "/api/brooklyn/"; | ||
| var baseURL = ""; | ||
|
|
||
| if (baseURL && settings.url.match(/^\/v1\/\w+/i)){ |
There was a problem hiding this comment.
minor, .indexOf('/v1/') == 0 would be more clear
There was a problem hiding this comment.
True it would be more clear, but the way it's currently set up is to intercept only calls to URLs that begin with /v1/, so something like /v1/projects will be affected, while /api/v1/projects won't.
If you use .indexOf('/v1/') == 0, /api/v1/projects will be affected as well.
There was a problem hiding this comment.
@sliceratwork i don't think so:
% node
> '/api/v1/project'.indexOf('/v1/')
4
btw we extend the prototype of String in brooklyn-utils.js so you could just write .startsWith('/v1/').
|
@CMoH quite clever to plug in at this level, I like it. Do you think the code should strip the |
|
Actually the credit goes to @sliceratwork - I merely wrote it on my machine. I don't know about the |
|
i like. in terms of future direction allowing the base url to be configurable at deploy time would be nice, though maybe difficult (?). minor preference but in future might be cleaner to swap all the |
|
PS good to merge once the regex / |
Add a function that prefixes AJAX REST requests with a configurable base URL. The base URL is inhere left empty for backward compatibility.
|
I switched to using |
This PR follows the proposal on the mailing list about allowing the REST API to be relocated relative to brooklyn's web UI.
For now the function is not changed, but this allows administrators to deploy Brooklyn's REST API and its UI indepentent of each other's base URLs.