rstudio / plumber

Turn your R code into a web API.
https://www.rplumber.io
Other
1.39k stars 255 forks source link

When serving static file at '/', '__docs__' returns 404 #811

Closed asbates closed 3 years ago

asbates commented 3 years ago

System details

Output of sessioninfo::session_info()():

─ Session info ───────────────────────────────────────────────
 setting  value                       
 version  R version 4.0.3 (2020-10-10)
 os       macOS Mojave 10.14.6        
 system   x86_64, darwin17.0          
 ui       RStudio                     
 language (EN)                        
 collate  en_US.UTF-8                 
 ctype    en_US.UTF-8                 
 tz       America/Los_Angeles         
 date     2021-06-11                  

─ Packages ───────────────────────────────────────────────────
 package     * version    date       lib
 assertthat    0.2.1      2019-03-21 [1]
 cli           2.2.0      2020-11-20 [1]
 clisymbols    1.2.0      2017-05-21 [1]
 crayon        1.4.1      2021-02-08 [1]
 ellipsis      0.3.2      2021-04-29 [1]
 fansi         0.4.1      2020-01-08 [1]
 glue          1.4.2      2020-08-27 [1]
 httpuv        1.6.1      2021-05-07 [1]
 jsonlite      1.7.2      2020-12-09 [1]
 later         1.2.0      2021-04-23 [1]
 lifecycle     1.0.0      2021-02-15 [1]
 magrittr      2.0.1      2020-11-17 [1]
 plumber       1.1.0.9000 2021-06-12 [1]
 promises      1.2.0.1    2021-02-11 [1]
 prompt        1.0.0      2020-11-22 [1]
 R6            2.5.0      2020-10-28 [1]
 Rcpp          1.0.6      2021-01-15 [1]
 rlang         0.4.11     2021-04-30 [1]
 rsconnect     0.8.16     2019-12-13 [1]
 rsthemes      0.1.0      2020-10-24 [1]
 rstudioapi    0.13       2020-11-12 [1]
 sessioninfo   1.1.1      2018-11-05 [1]
 stringi       1.6.2      2021-05-17 [1]
 swagger       3.33.1     2020-10-02 [1]
 webutils      1.1        2020-04-28 [1]
 withr         2.4.2      2021-04-18 [1]
 source                             
 CRAN (R 4.0.2)                     
 CRAN (R 4.0.2)                     
 CRAN (R 4.0.2)                     
 CRAN (R 4.0.2)                     
 CRAN (R 4.0.2)                     
 CRAN (R 4.0.2)                     
 CRAN (R 4.0.2)                     
 CRAN (R 4.0.2)                     
 CRAN (R 4.0.2)                     
 CRAN (R 4.0.2)                     
 CRAN (R 4.0.2)                     
 CRAN (R 4.0.2)                     
 Github (rstudio/plumber@9e7265d)   
 CRAN (R 4.0.2)                     
 Github (gaborcsardi/prompt@b332c42)
 CRAN (R 4.0.2)                     
 CRAN (R 4.0.2)                     
 CRAN (R 4.0.2)                     
 CRAN (R 4.0.2)                     
 Github (gadenbuie/rsthemes@6391fe5)
 CRAN (R 4.0.2)                     
 CRAN (R 4.0.2)                     
 CRAN (R 4.0.2)                     
 CRAN (R 4.0.2)                     
 CRAN (R 4.0.2)                     
 CRAN (R 4.0.2)                     

Example application or steps to reproduce the problem

File structure:

├── files
│   └── index.html
├── plumber.R

Contents of plumber.R where things work as expected:

#* @assets ./files
list()

#* @get /add
function(a,b) {
  as.integer(a) + as.integer(b)
}

Contents of plumber.R where things do not work as expected:

#* @assets ./files /
list()

#* @get /add
function(a,b) {
  as.integer(a) + as.integer(b)
}

Contents of index.html:

<h1>test</h1>

Describe the problem in detail

I have a plumber API where I'm trying to serve an html landing page at the root url. When using the annotation #* @assets ./files, I get index.html rendered properly at /public/, along with documentation at /__docs__/. When I use #* @assets ./files /, I get index.html rendered properly, but for the documentation I get a 404 error. Regardless of the path the app serves to (/public/ or /), the /add endpoint works.

I expect to be able to serve files at the root url with #* @assets ./files / and have the documentation served at /__docs__/.

meztez commented 3 years ago

Known issue with PR

https://github.com/rstudio/plumber/pull/748

asbates commented 3 years ago

Sorry for not doing do diligence in checking for related issues. I'll close this.