Skip to content
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

Merged
merged 1 commit into from
Apr 8, 2024

Conversation

gurneyalex
Copy link
Member

when a call is made with just a path, combine it with the collection's url

@OCA-git-bot
Copy link
Contributor

Hi @etobella,
some modules you are maintaining are being modified, check this out!

@gurneyalex gurneyalex force-pushed the 16.0_webservice_collection_url branch 2 times, most recently from 6ba8448 to 9bc0dc6 Compare March 4, 2024 18:18
url = self.collection.url
elif not url.startswith(self.collection.url):
if not url.startswith("http"):
url = self.collection.url + url
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
url = self.collection.url + url
url = f"{self.collection.url.rstrip('/')/{url.lstrip('/')"

Copy link
Contributor

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?

Copy link
Member Author

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?

Copy link
Contributor

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.

Copy link
Member Author

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?

@simahawk
Copy link
Contributor

do we need an update on the readme?

@gurneyalex
Copy link
Member Author

do we need an update on the readme?

I will make a PR enhancing the readme once #35 and #36 are merged.

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]>):
@gurneyalex gurneyalex force-pushed the 16.0_webservice_collection_url branch from 0d974bb to 9057e53 Compare April 8, 2024 16:31
@gurneyalex
Copy link
Member Author

/ocabot merge minor

@OCA-git-bot
Copy link
Contributor

On my way to merge this fine PR!
Prepared branch 16.0-ocabot-merge-pr-36-by-gurneyalex-bump-minor, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 7fb61cb into OCA:16.0 Apr 8, 2024
5 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at c28decf. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants