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

provide custom event params via extra attribute #34

Merged
merged 2 commits into from
Mar 15, 2021

Conversation

mahenzon
Copy link
Contributor

@mahenzon mahenzon commented Mar 13, 2021

Custom method can be now declared for events via extra config. Sure it can be just a POST method, but why not giving some more options, plus this extra can be loaded with other stuff later.

For example, custom url_suffix can be provided too. So instead of /user/{id}/event_update_user_online_status/ url will be /user/{id}/update_online/.

from flask import request
from combojsonapi.event.resource import EventsResource


class UserDetailEvents(EventsResource):
    def event_update_user_online_status(self, *args, **kwargs):
        # language=YAML
        """
        ---
        # some description
        """
        result = some_custom_stuff_to_do(kwargs, request.json)
        return result

    event_update_user_online_status.extra = {
        "method": "PUT",
        "url_suffix": "update_online",
    }

@mahenzon mahenzon requested a review from Znbiz March 13, 2021 18:03
@mahenzon mahenzon force-pushed the feature/custom-event-params branch from 6d28efe to 5b92e16 Compare March 14, 2021 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants