-
-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IMP] webservice: combine the url with collection's url #36
[IMP] webservice: combine the url with collection's url #36
Conversation
Hi @etobella, |
6ba8448
to
9bc0dc6
Compare
url = self.collection.url | ||
elif not url.startswith(self.collection.url): | ||
if not url.startswith("http"): | ||
url = self.collection.url + url |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
url = self.collection.url + url | |
url = f"{self.collection.url.rstrip('/')/{url.lstrip('/')" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: why would you use this in favor of url params?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently it is possible to use to send http requests on a different url (different name even) => I'm not fond of this but I don't want to break code that could use this "feature".
In my case, I have a number of endpoints to access which are on "https://some.service.provider/api-prefix" and I find it nicer to use call() with only the part of the URL which is after this bit. That first part of the URL is going to be different in integration and production, but the value which is passed to call() is going to be stable.
But maybe I'm missing soemthing obvious?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but that's exactly what url_params are for...
The base url will be different by env: fine, you have the env conf for it.
You will have something like https://sendto.me/prefix/{endpoint}/suffix
and you can pass endpoint=foo
as arg.
That's the idea. However this is probably a nice improvement for when the endpoint is always at the end of the URL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simahawk can you update your review?
do we need an update on the readme? |
when a call is made with just a path, combine it with the collection's url better combination of urls (Co-authored-by: Simone Orsi <[email protected]>):
0d974bb
to
9057e53
Compare
/ocabot merge minor |
On my way to merge this fine PR! |
Congratulations, your PR was merged at c28decf. Thanks a lot for contributing to OCA. ❤️ |
when a call is made with just a path, combine it with the collection's url