Skip to content

Instantly share code, notes, and snippets.

@randy3k

randy3k/server.R

Created Apr 6, 2020
Embed
What would you like to do?
preview private github repo
library(httpuv)
library(httr)
library(stringr)
app <- list(
call = function(req) {
paths <- str_split(req$PATH_INFO, "/")[[1]]
owner <- paths[2]
repo <- paths[3]
path <- str_c(paths[4:length(paths)])
r <- GET(
str_glue("https://raw.githubusercontent.com/{owner}/{repo}/master/{path}"),
add_headers(Authorization = paste("token", Sys.getenv("GITHUB_PAT")))
)
list(
status = 200L,
headers = list(
"Content-Type" = "text/html"
),
body = content(r, as = "text")
)
}
)
server <- runServer("0.0.0.0", 9454, app)
@randy3k

This comment has been minimized.

Copy link
Owner Author

@randy3k randy3k commented Apr 8, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment