Replies: 1 comment
-
Ring requests are just maps, we could even use pull patterns to match them; thus we can remove retit from our dependencies. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Context
In a classic backend API router, we would have different routes with different handlers for the different kind of actions to be performed.
Some of these routes might contain some authorisation middleware to ensure proper user permissions.
We do use this approach in our website still and the reitit router looks like this:
Pullable API
Since, all the routes for pull pattern accept the same
ring-handler
, which route we chose does not matter.The real API endpoints are actually highlighted as pure Clojure data in what we called the
pullable-data
:The advantages of using the
operation/pullable-data
as API routes are that:Caveat
We used to have reitit middlewares to validate user permissions before.
However, as we have seen above, since all routes use the same handler, we could just use a route without permissions restrictions to perform critical actions (such as deleting a post for instance).
This issue #219 has been fixed in the PR #220. The authorisation has been moved to the
pullable-data
as you can see with the different call towith-role
.This makes sense because, once again, the
pullable-data
is the real API of the SPA (aside from a few login related routes).Proposition
I suggest we should just have a unique reitit route for all requests like so:
Also, since the pull pattern allows us to perform multiple actions at once and fetch different information at once, choosing only one route would be misleading and hide some of the actions that would be performed.
For instance, in our
evt.app/initialize
re-frame event:We can see that this pattern does a few things:
However, the route name is
"/posts/all"
which does not reflect the user action.That's why, I think just having a generic route and let the pattern be the descriptions of what is being performed.
In some way, the pull-pattern is the routes.
@robertluo what do you think?
Beta Was this translation helpful? Give feedback.
All reactions