Create a handler functionλ︎
So far we have just sent back the same response map. To make our webapp more useful then we should have functions that return different web pages and resources (like JSON for API's).
In Ring terminology, these functions are referred to as a handler. They handler a request and return a response.
When you send a request to the webapp, the ring adaptor converts this request to a map and sends it to the specified handler.
A handler function takes the request map as its argument and returns a response map.
Note::Add separate handler functionλ︎
Refactor the code in the
src/todo-list/core.cljfile to create a separate
welcomehandler function that processes all requests
-mainfunction to call the
Run the server againλ︎
Save code changes and run the web server (use Control-c if you need to stop the server first)
Your webapp should behave exactly as it did before, check by visiting http://localhost:8000.
In the middleware section the
wrap-reloadring middleware component is used to automatically reload code changes into the running application, so no need to restart the webserver unless we have to add a dependency.