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

Provide a assets.fileExists() function or make assets.serve() throw #41

Open
enyo opened this issue Aug 10, 2015 · 2 comments
Open

Provide a assets.fileExists() function or make assets.serve() throw #41

enyo opened this issue Aug 10, 2015 · 2 comments

Comments

@enyo
Copy link
Contributor

enyo commented Aug 10, 2015

I want to render my own 404 pages, but Assets doesn't give me a clean way to do that.

It would be great if one of those could be implemented:

  1. an assets.fileExists() function, so I can check if the file exists
  2. a way to call assets.serve() so it throws an exception instead of responding with 404 itself.

What I'm doing to get this working is:

try {
  await gae.context.assets.read();
  gae.context.assets.serve();
}
on gae.AssetError {
  // Render my own 404 page
}

which obviously is less than ideal.

@enyo
Copy link
Contributor Author

enyo commented Aug 10, 2015

If you tell me which version you'd prefer I can create a PR.

@sgjesse
Copy link
Contributor

sgjesse commented Aug 10, 2015

Having asset.exists([String path]) would be a good API. This only issue is that if the underlying file system is changed between a call to exists and server or read the builtin 404 could still be returned. However for a deployed server the content in build/web is not supposed to change.

Saying that build/web is not supposed to change can also make it possible to cache the result of exists calls and potentially what is read by server or read as well.

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