Define routes in middleware

Skip to first unread message

Yang Yang

Feb 2, 2017, 6:01:33 PM2/2/17
to Ring
Hi all,
I am currently adding a mock data middleware into my application.

My idea is using middleware as a mock server, and integrate with the production code. When an endpoint is not implemented in the app, it returns a mock data from middleware layer.


saying there's a server 


request a (GET: /not-in-app)

goes into the server, and hit middleware route (:/not-in-app) and return.

request a (GET: /in-app)

goes into the app, and hit middleware route somehow aware the app already handled the request and transparently pass the result to client.

I wonder is that possible, or in this scenario is middleware the best choice?


James Reeves

Feb 2, 2017, 6:52:44 PM2/2/17
to Ring
Why not use a catch-all route? Routes in Compojure (which I guess you're using?) are matched in order, so if you add a route after all of your others, that will be triggered only if all the other routes don't match.

- James

You received this message because you are subscribed to the Google Groups "Ring" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
For more options, visit

Reply all
Reply to author
0 new messages