rstudio / httpuv

HTTP and WebSocket server package for R
Other
229 stars 86 forks source link

Add option to exclude subdirs in static paths #197

Closed wch closed 5 years ago

wch commented 5 years ago

This is needed to fix rstudio/shiny#2325. It adds the ability to exclude subdirectories of static paths.

Example usage:

s <- startServer("127.0.0.1", 5000,
  list(
    call = function(req) {
      # Return a 403 for the R code path; the C++ code path will return 404
      # for missing files.
      return(list(
        status = 403,
        body = paste0("403 forbidden: ", req$PATH_INFO)
      ))
    },
    staticPaths = list(
      "/" = staticPath("."),
      "/excluded_dir" = excludeStaticPath(),
      "sensitive_data.csv" = excludeStaticPath()
    )
  )
)

Note: this example has been updated.