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

Determine new decorator API #20

Open
pydanny opened this issue Jul 10, 2022 · 0 comments
Open

Determine new decorator API #20

pydanny opened this issue Jul 10, 2022 · 0 comments

Comments

@pydanny
Copy link
Owner

pydanny commented Jul 10, 2022

Objectives for new design

The current design is ungainly in places, let's improve on it!

Old API

Problems:

  1. Long argument names
  2. url, encoding, timeout, custom_headers, and signing secret added to request/response by the decorator. What's a better way to do it?
>>> @webhook(sender_callable=targeted.sender, hash_function=uuid.uuid4)
>>> def basic(wife, husband, url, encoding, timeout, custom_headers, signing_secret):
>>>     return {"husband": husband, "wife": wife}

New API

Objectives:

  1. Shorten argument names for ease of use
  2. Add a recorder decorator argument so implementors can save results to logs, db, or whatever they way
  3. TODO Try to find a better way to add url, encoding, timeout, custom_headers, and signing_secret to requests
>>> import uuid
>>> from webhook import webhook
>>> from mystff import sender_func, save_to_db
>>>
>>> @webhook(sender=sender_func, hasher=uuid.uuid4, recorder=save_to_db)
>>> async def basic(wife, husband, url, encoding, timeout, custom_headers, signing_secret):
>>>     # I'm not happy with how arguments are managed right now, still thinking about it
>>>     return {"husband": husband, "wife": wife}
>>> await basic(...args here)
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

No branches or pull requests

1 participant