Bootstrap project for the Spring Boot REST tutorial found here: https://spring.io/guides/tutorials/bookmarks/
The tutorial includes four main steps:
- Building the model
- Building a REST service
- Building a HATEOAS REST Service
- Securing a REST Service
Each step is executed in a separate module of the project.
This project contains the four modules (model, rest, hateoas, security) and complete build.gradle file and can be used as a starting point when following the tutorial.
The REST, HATEOAS and security step/module contains an Application class with a main method starting the application.
The application in each step can be started either by running the Application class from your IDE or with Gradle. To do the latter just run the below command for the module you want to start, for example:
./gradlew :rest:bootRun
You can use cURL to test your application at the different steps. Some example commands follows.
Get all bookmarks for user jhoeller:
curl -v GET http://127.0.0.1:8080/jhoeller/bookmarks
Add a new bookmark for user jhoeller:
curl -X POST -v -H "Content-Type: application/json" -d '{"uri":"the uri", "description":"the description"}' http://127.0.0.1:8080/jhoeller/bookmarks
NB! Windows users might need to escape double quotes in the json.
-
Login / get access token for user jhoeller:
curl -X POST -vu android-bookmarks:123456 http://localhost:8080/oauth/token -H "Accept: application/json" -d "password=password&username=jhoeller&grant_type=password&scope=write&client_secret=123456&client_id=android-bookmarks"
-
Get all bookmarks (for user jhoeller):
curl -v GET http://127.0.0.1:8080/bookmarks -H "Authorization: Bearer [access_token from response in above POST request]"
(NB! The second example request at the top of the security step Application class in the tutorial is incorrect.)