Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

root static file handler causes /__docs__/ to 404 #881

Open
aronatkins opened this issue Sep 28, 2022 · 1 comment · May be fixed by #882
Open

root static file handler causes /__docs__/ to 404 #881

aronatkins opened this issue Sep 28, 2022 · 1 comment · May be fixed by #882

Comments

@aronatkins
Copy link
Contributor

System details

Output of sessioninfo::session_info()():

# sessioninfo::session_info() output goes here

Example application or steps to reproduce the problem

The plumber.R file.

#* @assets ./static /
list()

#* Say hello.
#* @get /hello
function() {
  list(msg = "Hello.")
}

The static/index.html file.

<html>
<head>
<title>static</title>
</head>
<body>
this is static.
</body>
</html>

This is the R command run by the RStudio IDE "Run API" button, but it can also be run from the R console.

plumber::plumb(file='plumber.R')$run()
# => Running plumber API at http://127.0.0.1:6385
# => Running swagger Docs at http://127.0.0.1:6385/__docs__/

The RStudio IDE attempts to launch the documentation in its Viewer pane, which shows the 404 message. You can also see the 404 from curl:

curl http://127.0.0.1:6385/__docs__/
# => {"error":"404 - Resource Not Found"}

Describe the problem in detail

The /__docs__/ route responds with a 404 rather than serving the API documentation. The server indicates that documentation is available during startup.

@aronatkins
Copy link
Contributor Author

As a workaround, the Plumber API can return the root HTML as an API response and then serve the remainder of the static assets from an alternate route.

Here is a partial AIP definition that hosts static files at /static and has in-code HTML for the root request.

#* @assets ./static /static
list()

#* @serializer html
#* @get /
index <- function() {
  "<html>
<head>
<title>static</title>
</head>
<body>
this is static from the API.
</body>
</html>
"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant