Custom routes in shiny

135 views
Skip to first unread message

Kadrach IsFictious

unread,
Sep 28, 2016, 1:59:34 AM9/28/16
to Shiny - Web Framework for R
Hi all,

is it possible within Shiny to expose a global (as in, not per session) POST endpoint, with a configurable handler? My specific use case here is to receive/process Amazon SNS messages, in turn causing a refresh of a data source.

While I can hijack registerDataObj, this requires apriori knowledge of the session token (etc) to construct the actual URL.

Does Shiny at all expose its internal routing handlers?

I would appreciate any guidance you can offer. While I can likely monkey patch my way around, I do not understand the internal routing well enough to know where best to start.

Cheers,

Kadrach

Dean Attali

unread,
Sep 28, 2016, 4:03:20 PM9/28/16
to Shiny - Web Framework for R
You might want to take a look at the plumber package. There's a page on the documentation website that helps you with setting it up so that it always runs

Erik Westlund

unread,
Sep 28, 2016, 4:31:08 PM9/28/16
to Kadrach IsFictious, Shiny - Web Framework for R
Shiny is amazing but it seems like there are better ways to achieve what you want.

I'd use tried and true frameworks with battle-tested SNS packages, such as Laravel (PHP), Django (Python), or Rails (ruby), to handle the data processing you are describing.  

Use a database driver in R to connect to the database driving the above app.

Then make your shiny app do what you need it to.

If you have the knowledge of SNS, tokens, etc. this is going to be far faster than hacking around R/Shiny.


The only reason not to do this would be if some reason you need the above data to be immediately reactive. Even then, I think polling your database in R periodically for data updates would still be easier.


My 2 cents

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/c9c0576c-b04f-40c9-9c98-ce367de27375%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kadrach IsFictious

unread,
Sep 28, 2016, 7:45:13 PM9/28/16
to Shiny - Web Framework for R, kad...@gmail.com
Hi Erik, 

> The only reason not to do this would be if some reason you need the above data to be immediately reactive. Even then, I think polling your database in R periodically for data updates would still be easier.

thank you for your feedback. The data does indeed need to be available to the end-user as soon as possible. Updates come sporadically and possibly in bursts, hence my reluctance to polling.

I'll see what I can come up with :)

On Thursday, September 29, 2016 at 6:31:08 AM UTC+10, Erik Westlund wrote:
Shiny is amazing but it seems like there are better ways to achieve what you want.

I'd use tried and true frameworks with battle-tested SNS packages, such as Laravel (PHP), Django (Python), or Rails (ruby), to handle the data processing you are describing.  

Use a database driver in R to connect to the database driving the above app.

Then make your shiny app do what you need it to.

If you have the knowledge of SNS, tokens, etc. this is going to be far faster than hacking around R/Shiny.


The only reason not to do this would be if some reason you need the above data to be immediately reactive. Even then, I think polling your database in R periodically for data updates would still be easier.


My 2 cents
On Wed, Sep 28, 2016 at 12:59 AM, Kadrach IsFictious <kad...@gmail.com> wrote:
Hi all,

is it possible within Shiny to expose a global (as in, not per session) POST endpoint, with a configurable handler? My specific use case here is to receive/process Amazon SNS messages, in turn causing a refresh of a data source.

While I can hijack registerDataObj, this requires apriori knowledge of the session token (etc) to construct the actual URL.

Does Shiny at all expose its internal routing handlers?

I would appreciate any guidance you can offer. While I can likely monkey patch my way around, I do not understand the internal routing well enough to know where best to start.

Cheers,

Kadrach

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.

Joe Cheng

unread,
Sep 28, 2016, 8:02:27 PM9/28/16
to Kadrach IsFictious, Shiny - Web Framework for R
I may have a solution for you very soon...

Joe Cheng [RStudio]

unread,
Sep 28, 2016, 8:07:42 PM9/28/16
to Shiny - Web Framework for R, kad...@gmail.com
I filed a tracking issue here: https://github.com/rstudio/shiny/issues/1394
Reply all
Reply to author
Forward
0 new messages