Fork me on GitHub
#pedestal
<
2021-01-12
>
dangercoder21:01:35

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

dangercoder21:01:03

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

dangercoder21:01:09

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

ddeaguiar21:01:16

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.

👍 3
ddeaguiar21:01:10

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

ddeaguiar21:01:17

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)

👍 3
dangercoder21:01:40

Thanks @U0FL657GR your answer was exactly what I was looking for 🙂

👍 3
simongray10:01:42

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.

souenzzo11:01:03

I use ::http/not-found-interceptor

🙏 3
simongray16:01:21

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