Skip to content

Multiple handlers #21

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
nine-2-five opened this issue Dec 20, 2016 · 5 comments
Closed

Multiple handlers #21

nine-2-five opened this issue Dec 20, 2016 · 5 comments
Assignees

Comments

@nine-2-five
Copy link

nine-2-five commented Dec 20, 2016

Is having a multiple webhook handlers in a single node script a supported code path?
Like:
http://example.com/pushmepullme/23
http://example.com/pushmepullme/36
http://example.com/pushmepullme/37

I tried creating an array of handlers but it seems to only work with element 0.

@rjz
Copy link
Collaborator

rjz commented Dec 20, 2016

It should be possible to create multiple handlers and chain them through their error handlers, but I wonder if the use-case could be addressed (given knowledge of the inbound events) by a single handler.

handler.on('issues', function (event) {
  switch(event.payload.repository.id) {
    case 23: return doThis();
    case 36: return doThat();
    case 37: return doSomethingElseEntirely();
  }
});

Would something like this work for what you have in mind?

@nine-2-five
Copy link
Author

In my case even the url must be different because (correct me if I'm wrong) I can't send custom data from github and I can have multiple "deployment scenarios/users" per single repository. I need to somehow pass in the deployment_id.
That is the number at the end of my sample url: http://example.com/pushmepullme/23 <- deploy_id

@rjz
Copy link
Collaborator

rjz commented Dec 20, 2016

Got it––thanks, @isvaljek. Is there any way to configure the deployment scenarios/users within the app (rather than within github), though?

(please forgive all the questions! Just trying to imagine any alternative approaches that could address the specific need before we contemplate a code change to address it.)

@nine-2-five
Copy link
Author

nine-2-five commented Dec 20, 2016

@rjz I grab the deployment details from a different app by deploy_id. It's just an xhr call to the other app, so I guess it could all be stored locally. What I meant to say is that I don't know of a way to pass any extra data from github webhook to my app.
So, having to create a webhook url beforehand, I'm cornered into hardcoding the deployment_id into both github webhook and my app.
My app only has knowledge of deploy_ids so I thought I could create an array of handlers with your package that are 1:1 with github webhook urls.

@rjz rjz self-assigned this Jan 6, 2017
@rjz
Copy link
Collaborator

rjz commented Feb 22, 2017

There's been additional discussion of a similar case in #22 that I believe could address this need. Closing this out to move further discussion over there, but please correct me if my understanding's off-base!

@rjz rjz closed this as completed Feb 22, 2017
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants