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

Expose raw Request object with rejections #684

Closed
jsdw opened this issue Aug 8, 2020 · 1 comment
Closed

Expose raw Request object with rejections #684

jsdw opened this issue Aug 8, 2020 · 1 comment
Labels
feature New feature or request

Comments

@jsdw
Copy link

jsdw commented Aug 8, 2020

When an error occurs, I want to be able to respond to the user with something appropriate.

In the general case I'd like to look at the Accepts header and work out from that whether to provide the error back in the form of JSON or plain text or html.

In the specific case of serving static files, I'd also like to look at the request path so that I can use it alongside the Accepts header to figure out whether or to serve a root index.html file or return a 404 (to play nicely with the browser history API when doing client side routing. Logic is along the lines of; do they accept text/html, and does the path not end with an extension).

If when catching errors using recover, I had access to the underlying Request made by the user, I'd be able to achieve both of these things quite nicely.

@jsdw jsdw added the feature New feature or request label Aug 8, 2020
@jxs
Copy link
Collaborator

jxs commented Aug 8, 2020

In the general case I'd like to look at the Accepts header and work out from that whether to provide the error back in the form of JSON or plain text or html.

that can be done by returning different Rejection's according to the Accepts header.

regarding the specific usecase for the fs filter, see #209 (comment)

@jxs jxs closed this as completed Aug 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants