Story #6570
as a plugin writer, my custom content handler can handle requests for CONTENT_PATH_PREFIX
100%
Description
Motivation
Plugins that need to have some custom logic for serving content can provide a custom content Handler. Up till now, each plugin that needed a custom handler, did so because it needed to provide an API that was rooted somewhere other than CONTENT_PATH_PREFIX[0].
The RPM plugin wants to provide a repo.config file that is dynamically generated based on the distribution's 'base_path' and 'base_url'[1] . It does not need to serve an API rooted at a different path.
Implemenation
- Add a hook method to BaseDistribution named content_handler() which would provide a no-op as it's base functionality and return None by default. It would take subpath as the single param and that would be the url portion after the distribution's base_path (the remaining part).
- In the content app just after the Distribution is matched and permit() is called we have the content app call this new
content_handler
. That would roughly be here. - If the
content_handler(subpath)
returns a subclass of aiohttp.web.Response(...) then return that and don't continue to call the rest of the code in the content app.
[0] https://docs.pulpproject.org/settings.html#content-path-prefix [1] https://pulp.plan.io/issues/5356
Related issues
Associated revisions
Revision a0fce1f1
View on GitHub
Add content_handler_directory_listing in Dist
This allows plugin writers to add files served by content_handler to show up in the directory listings.
ref #6570
Revision 6563722b
View on GitHub
Add documentation for content_handler
closes #6570
History
#1
Updated by dkliban@redhat.com 12 months ago
- Tracker changed from Issue to Story
- % Done set to 0
#2
Updated by dkliban@redhat.com 12 months ago
- Related to Story #5356: As a user, I can download a configuration for yum/dnf from an RpmDistribution added
#3
Updated by Anonymous 12 months ago
- Status changed from NEW to MODIFIED
- % Done changed from 0 to 100
Applied in changeset pulpcore|6563722beb15a854e82e12d32cf5c6c6efadeccf.
#4
Updated by dkliban@redhat.com 11 months ago
- Status changed from MODIFIED to CLOSED - CURRENTRELEASE
- Sprint/Milestone set to 3.4.0
Please register to edit this issue
Implement content_handler for BaseDistribution
This allows Plugin writers to serve non-Artifact content.
ref #6570