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

Support 404.html #19

Open
kiootic opened this issue Feb 26, 2024 · 2 comments
Open

Support 404.html #19

kiootic opened this issue Feb 26, 2024 · 2 comments

Comments

@kiootic
Copy link
Collaborator

kiootic commented Feb 26, 2024

  • If file not found, show 404.html
    • /index.html not found, try /404.html
    • /foo/index.html not found, try /foo/404.html & /404.html
  • Status code keep 404.
@toshinari123
Copy link
Contributor

  • create error_handler.go in internal/handler/site, which has an handleError func
  • handleError is recursive as follows:
    • serveFile will call handleError if not found, then it will call back serveFile to serve 404
    • if that serveFile call is not found, it will call handleError which goes up a layer in the path

write handleError [2 hours]
test handleError by adding 404 in root of example and adding subdirectoies [2 hours]
write error_handler_test.go [4 hours]

@kiootic
Copy link
Collaborator Author

kiootic commented Feb 26, 2024

  • Please make it a middleware; I'd expect it to rewrite the URL path into 404.html if the requested path does not exists, and pass the updated URL to the site handler.
  • Please avoid unneeded recursive function; it should be easy to implement the logic without recursion in this case.

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

No branches or pull requests

2 participants