Putting it all together — Let’s serve a page from Play
So you’re going to need to return a Result. This is a Play Framework thing, you get a Request, you give the Request a Result, and it’s satisfied.
Here’s the charity controller, with the method to show the index page
Connecting the route
‘when a user hits this route, direct them to this method in this controller?’
Edit routes in /conf
Here we use both of the above methods. When / is called, return all of the results, and when you go to /donate as a GET request, redirect me to index, where I will again return all of the results.
Now you have a fully functioning Play application that does the following:
- Creates an in memory DB
- Creates a table called charity
- Maps charity object to a charity table
- Can query the charity table with all of the methods defined in CharityRepository
- If you navigate to :9000 of localhost you can see a full index page of the rendered contents (I skipped the twirl templates, but they are in the repo under views)