pedestal

dangercoder 2021-01-12T21:22:35.312100Z

Is it possible to define a default route in pedestal? e.g. if I don't get any hits, call this interceptor/handler.

simongray 2021-01-13T10:36:42.313600Z

One could well imagine wanting to use a different route resolution algorithm while also having a default handler specified, right? It’s a bit sad that it’s complected like that.

souenzzo 2021-01-13T11:32:03.313900Z

I use ::http/not-found-interceptor

πŸ™ 1
simongray 2021-01-13T14:30:37.314300Z

Aha!

souenzzo 2021-01-13T16:16:32.314500Z

For browsers, consider 303 + Location https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location

simongray 2021-01-13T16:28:21.314800Z

Right, doing an explicit redirect makes a lot of sense.

dangercoder 2021-01-12T21:23:03.312200Z

Ive done something similar with Reitit + Ring in the past. There you could define a "default handler".

dangercoder 2021-01-12T21:25:09.312400Z

One way to do it is to add a default interceptor that takes care of it.

2021-01-12T21:25:16.312600Z

You can do so be specifying a catch-all route and using the linear-search router. The caveat is that the catchall route needs to be the last one specified.

πŸ‘ 1
2021-01-12T21:26:10.312900Z

You either use the terse route syntax or the table-routes fn to expand your routes directly

2021-01-12T21:27:17.313100Z

Funny enough I was just looking at adding this info to the docs. It came up some time ago in the pedestal user groups (https://groups.google.com/g/pedestal-users/c/lkrODbKivaU/m/cOtDLJNBDQAJ)

πŸ‘ 1
dangercoder 2021-01-12T21:29:40.313300Z

Thanks @ddeaguiar your answer was exactly what I was looking for πŸ™‚

πŸ‘ 1