Skip to content

Commit

Permalink
add function to get service url
Browse files Browse the repository at this point in the history
  • Loading branch information
jjallaire committed Oct 4, 2013
1 parent e4f32b6 commit 4705425
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions R/http.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@ userAgent <- function() {
paste("shinyapps", packageVersion("shinyapps"), sep="/")
}

serviceUrl <- function() {
parseHttpUrl(getOption("shinyapps.service_url",
"https://api.shinyapps.io/v1"))
}

parseHttpUrl <- function(urlText) {

matches <- regexec("(http|https)://([^:/#?]+)(?::(\\d+))?(.*)", urlText)
components <- regmatches(urlText, matches)[[1]]
if (length(components) == 0)
stop("Invalid url: ", urlText)

url <- list()
url$protocol <- components[[2]]
url$host <- components[[3]]
url$port <- components[[4]]
url$path <- components[[5]]
url
}

parseHttpHeader <- function(header) {
split <- strsplit(header, ": ")[[1]]
if (length(split) == 2)
Expand Down

0 comments on commit 4705425

Please sign in to comment.