jooby icon indicating copy to clipboard operation
jooby copied to clipboard

SPAs support using asset handler

Open ajcamilo opened this issue 7 years ago • 2 comments

In jooby 2.0, assets("/?*") should work like a site, meaning assets not found in the filesystem or classpath, should return index.html.

The key difference is the /?* mapping. This mapping add support for base root mapping:
* GET /docs ⇒ /docs/index.html
* GET /docs/about.html ⇒ /docs/about.html
* GET /docs/note ⇒ /docs/index.html

But the way AssetHandler is implement, the third case (GET /docs/note ⇒ /docs/index.html) does not work, return 404.

My suggestion is that assets not found should not return 404 but continue to flow in the chain of routes. What do you think?

ajcamilo avatar Jul 10 '19 16:07 ajcamilo

There is no concept of chain of route in 2.x... or it is not like in 1.x

In 2.x an asset mapping (or any other mapping) must resolve the response or trigger a 404 (in case of asset handler).

Then this:

GET /docs/note

Must be resolved to:

/docs/note/index.html

Not: /docs/index.html

isn't working?

jknack avatar Jul 10 '19 17:07 jknack

Actually what I need in my use case is:

GET /docs/note -> /docs/index.html or any asset that does not exist, fallback to index.html

Without the chain concept, how can I achieve this?

ajcamilo avatar Jul 11 '19 09:07 ajcamilo