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

Support Custom Webhooks and Replace Echo Dependency with Native HTTP #9

Open
Lenstack opened this issue Jan 13, 2025 · 2 comments
Open

Comments

@Lenstack
Copy link

This request proposes adding support for custom webhooks and replacing the current dependency on the Echo framework with native HTTP functionality.

In internal/manager/webhook_manager.go

Benefits:

  • Flexibility: Supporting custom webhooks will allow users to integrate the system with a wider variety of services.
  • Reduced Dependencies: Replacing Echo with native HTTP can simplify the project and reduce potential security and maintenance concerns associated with external libraries.
@sarthakjdev
Copy link
Member

Hello @Lenstack,

Regarding the custom webhook feature, the current implementation supports the following workaround:

The GetWebhookGetRequestHandler method returns a GET request handler for the webhook, while GetWebhookPostRequestHandler provides a POST request handler.

postHandler := wapiClient.GetWebhookPostRequestHandler()
err := postHandler(context) // This can be invoked inside any custom webhook handler, whether using Echo, native HTTP, or other server types.

To use this functionality, simply omit the webhookPath parameter when creating the client. When the webhookPath is not provided, the SDK is designed to skip creating a webhook server. Instead, it functions as a component utility, allowing you to utilize the webhook handlers (GetWebhookPostRequestHandler or GetWebhookGetRequestHandler) as needed.

I’d also like to better understand your perspective on switching to native http. Specifically:

  1. Why do you think we should switch to native http?
  2. Do we need to extend support for multiple server dependencies (e.g., Echo, native HTTP, Gin, etc.)? Possibly if the above setup works in your case?

@Lenstack
Copy link
Author

Hello @sarthakjdev

Thanks for your fast response.

I did try to use the same proposal you told me "postHandler := apiClient.GetWebhookPost RequestHandler() err := post Handler(context)" before to post this request but dont works when i want to assign a custom context, in my case.

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

2 participants