I am not sure if that really addresses your problem, but since you mentioned shiny.router, I think the plumber package might also be useful.
This is a small example, that lets you create an image tag using an R function as API.
plumber.R
library(shiny)
library(plumber)
#' Get an image tag with source from its name
#' @param imgsrc Source of the image
#' @get /
img2tag <- function(imgsrc = "") {
url = paste0('https://shinyserver.com/app/', imgsrc)
as.character(tags$img(src=url))
}
Then you have to start the plumber API by entering:
pr <- plumber::plumb("plumber.R")
pr$run(port = 7818)
And then you can access it in the browser via:
http://localhost:7818/?imgsrc=image123.jpeg
which gives you the JSON-aquivalent of the string:
0 "<img src=\"https://shinyserver.com/app/image123.jpeg\"/>"
or through the console with:
curl http://localhost:7818/?imgsrc=image123.jpeg