DEV Community

Alex Laird
Alex Laird

Posted on • Edited on

hookee - command line webhooks, on demand

pyngrok - a Python wrapper for ngrok

hookee is a utility that provides command line webhooks, on demand! Dump useful request data to the console, process requests and responses, customize response data, and configure hookee and its routes further in any number of ways through custom plugins.

Installation

hookee is available on PyPI and can be installed using pip:

pip install hookee
Enter fullscreen mode Exit fullscreen mode

or conda:

conda install -c conda-forge hookee
Enter fullscreen mode Exit fullscreen mode

That's it! hookee is now installed.

Basic Usage

hookee makes it easy to get webhooks on the fly right from the console. Simply start it with:

hookee start
Enter fullscreen mode Exit fullscreen mode

With its default configuration, this will start a server on port 5000, open a ngrok tunnel using pyngrok, and mount a URL at /webhook. Sending any request to the /webhook endpoint will dump the request and response data to the console.

hookee can be configured in a number of ways to quickly and easily tweak request and response data. For example, here we are customizing the response body from /webhook using the --response arg.

hookee --response "<Response>Ok</Response>" --content-type application/xml
Enter fullscreen mode Exit fullscreen mode

hookee can also be started without a tunnel (removing the dependency on an Internet connection). Using the --no-tunnel flag only starts hookee's server, allowing responses to be mocked locally. This can be particularly useful when service discovery is done through a proxy service (ex. HAProxy, Envoy, etc.), meaning we can tell hookee to start on the port of an expected downstream, thus intercepting requests to that service to provide our own responses in an isolated environment, very useful for rapid local development, cluster testing, and more.

hookee --no-tunnel --response "<Response>Ok</Response>" --content-type application/xml --default-route /some/route --port 19780
Enter fullscreen mode Exit fullscreen mode

To see the ways hookee can be tweaked right from the console, view its documented args and commands like this:

hookee --help
Enter fullscreen mode Exit fullscreen mode

Documentation

For more advanced usage, including how hookee default configuration can be changed, extended through plugins, and more, see its official documentation is available at http://hookee.readthedocs.io.

Contributing

If you would like to get involved, be sure to review the Contribution Guide.

Want to contribute financially? If you've found hookee useful, sponsorship would also be greatly appreciated!

Top comments (0)