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

Added defaultFilePath option to directory handler #48

Closed
wants to merge 4 commits into from

Conversation

fbaiodias
Copy link

Hey,

I'm using inert to serve web apps with client side routing and didn't find an easy way of specifying the default file to be served on sub paths.

I know I could use a global onPreResponse handler to check if the response was 404 and reply with the default file instead, but that also catches other REST endpoints that I don't want to modify.

Let me know what you think of this :)

@kanongil
Copy link
Contributor

Thanks for the PR. Your use-case seems to be related to #41, though @digitaldesigndj was using the reply.file() interface. Ideally, I'd prefer a patch that covers both use-cases, which yours does not.

Regarding the extension handler case: Note that you can sandbox extension handlers to the current plugin, and that you can lookup app specific route data using request.route.settings.app.

I'll look further into it later.

@kanongil kanongil added the feature New functionality or improvement label Oct 24, 2015
@digitaldesigndj
Copy link

Ok, I have to admit that I don't fully understand anything right now.

But with that disclaimer, I am comfortable saying that detecting Inert failure (with data!) seems like a useful use case?

I am very happy to see an enhancement tag here! Also super Hapi to say that I write server side coffee.

@JJayet
Copy link

JJayet commented Mar 29, 2017

Hi,

Is there anyway to pass this PR ?

I have the exact same use-case (using Hapi to serve an Angular 2 (well 4 :)) webapp) and without those changes, I cannot reload my page without having a 404.

I'm not sure it related to #41 actually. It does cover some of the same ground but the end result is not the same (or I'm missing something).

@kanongil
Copy link
Contributor

@JJayet I'm looking into it right now, actually.

Both this and #41 essentially want to do "something" when a file is not found.

I am reluctant to merge this PR, since it only applies to a very specific "something", and I would much prefer a solution that applies to more use-cases. Especially when this can already be handled, albeit in a convoluted, sub-optimal manner, with the existing framework apis.

@JJayet
Copy link

JJayet commented Mar 29, 2017

@kanongil I get it.
Hopefully you'll find a solution soon but in the mean time, I had to implement @fbaiodias solution which seems kind of elegant for that particular use case.

Is there anything I could do to help you ?

@sledorze
Copy link

Same need here, hapi and angular4 (so SPA routing involved).
@kanongil Any timeframe for this pressing feature? I'll use @fbaiodias solution too meanwhile.

@hueniverse
Copy link
Contributor

Is this still happening or should we close it?

@fbaiodias fbaiodias closed this Sep 27, 2018
@lock
Copy link

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature New functionality or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants