Actions
Story #6570
closedas a plugin writer, my custom content handler can handle requests for CONTENT_PATH_PREFIX
Start date:
Due date:
% Done:
100%
Estimated time:
Platform Release:
Groomed:
No
Sprint Candidate:
No
Tags:
Sprint:
Quarter:
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
Actions
Implement content_handler for BaseDistribution
This allows Plugin writers to serve non-Artifact content.
ref #6570