-
Book Overview & Buying
-
Table Of Contents
Clojure Web Development Essentials
By :
There are typically three things we need to do when handling form input: validate the input, show an error message if the input is invalid, and show a success message when the input is valid and accepted.
In order for us to validate the form input, we need to create a route where the form will POST. We made a number of these in the previous chapter, so we'll draw on that experience and pattern.
Let's create a new route for the same URL, /signup, but this time we'll ensure that it accepts a POST request instead of a GET request. We'll put it along with the existing /signup GET route in our hipstr.routes.home namespace:
(defroutes home-routes
(GET "/" [] (home-page))
(GET "/about" [] (about-page))
(GET "/signup" [] (signup-page))
(POST "/signup" [& form] (str "nice job"))
We now have two routes for the same URL, one that will handle the GET request, and another that will handle the POST request. You'll notice that GET doesn...
Change the font size
Change margin width
Change background colour