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

try_files for @std/http/file_server #5875

Open
redabacha opened this issue Aug 30, 2024 · 4 comments
Open

try_files for @std/http/file_server #5875

redabacha opened this issue Aug 30, 2024 · 4 comments
Labels
feedback welcome We want community's feedback on this issue or PR http suggestion a suggestion yet to be agreed

Comments

@redabacha
Copy link

Is your feature request related to a problem? Please describe.

there is currently no built-in way to attempt to serve a file from a directory and then handle when the file doesn't exist.

Describe the solution you'd like

a function similar to serveDir or serveDir itself but will throw or hand off back in some way to the caller to deal with when a file is missing, similar to the try_files directive in nginx.

Describe alternatives you've considered

building my own solution but i feel this would be a common enough use case to have as part of the standard library.

@iuioiua
Copy link
Collaborator

iuioiua commented Sep 2, 2024

Are you using serveDir() or using @std/http/file-server as a script? Please clarify. It seems you're using serveDir(). In that case, serveDir() serves a HTTP 404 Not Found response. If anything, I could understand perhaps adding a notFoundHandler option to serveDir().

@iuioiua iuioiua added suggestion a suggestion yet to be agreed http feedback welcome We want community's feedback on this issue or PR labels Sep 2, 2024
@redabacha
Copy link
Author

hi @iuioiua, yes that is correct i was referring to the serveDir() function being used in a running application. for existing reference, hono have a onNotFound handler as an option for serveStatic in all their supported runtimes, e.g. https://hono.dev/docs/getting-started/deno#onnotfound.

@iuioiua
Copy link
Collaborator

iuioiua commented Sep 3, 2024

WDYT about a notFoundHandler option, @kt3k?

@kt3k
Copy link
Member

kt3k commented Sep 4, 2024

The option like that makes sense to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback welcome We want community's feedback on this issue or PR http suggestion a suggestion yet to be agreed
Projects
None yet
Development

No branches or pull requests

3 participants