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

Event handlers and query param auth_token #7

Closed
wants to merge 3 commits into from

Conversation

masha256
Copy link

(Re-targeting of Shopify/dashing#675)

This pull request adds the following two features to dashing:

  • Allows the auth_token to be a query parameter in addition to being included in the POSTed widget json. This allows for wiring into hooks from 3rd party webhooks (like shopify!) where you cannot control the payload, just the URL.
  • Creates a new concept of an 'event handler' whereby backend ruby code can be invoked when widget JSON is received from a web request. It also creates a new http path called /trigger/:id to invoke the handler, but not have the payload rebroadcast to all the dashing web frontends. A simple use case allowing dashing to receive a webhook from some 3rd party, extract/normalize some data from it, and then formulate a send_event() that is broadcast to all the connected browser frontends.

A new widget I created allows dashing to play a sound via the html5 audio API when some backend webhook happens (such as a new e-commerce purchase from a shopify store ;)).

@terraboops
Copy link

IMHO, I think the querystring change should be part of dashing-contrib or a similar gem...

If it's not possible to refactor that into an extension, then perhaps we can refactor the innards of Dashing to allow it. Right now, the main app.rb file is not a class - so it cannot be monkey patched easily.

I am generally in favour of the concept of Middleware, which your Event Handler change seems to be leaning towards. I feel that Middleware enables huge flexibility at almost no cost to developers. That being said, perhaps instead of adding a new action to do custom triggers we could enhance send_event? A pipeline of middleware could be executed on the inputs to send_event before being forwarded off. Would this suit your usecase?

If you truly just want to add a new action that allows random event handlers to be executed, then I'd again recommend that goes into an extension gem. In this case, since you're adding new stuff only, it should be very easy to do.

@terraboops terraboops closed this May 26, 2017
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

Successfully merging this pull request may close these issues.

2 participants