Skip to content
This repository was archived by the owner on Oct 16, 2025. It is now read-only.
This repository was archived by the owner on Oct 16, 2025. It is now read-only.

Determine new decorator API #20

@pydanny

Description

@pydanny

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions