Based on Template for Spring Boot application
Includes web-server on port 9080 with /articles
endpoint exposed.
Supports CRUD set of operations and R with pagination
- Maven 3
- JDK 21
mvn clean install
docker build ./ -t client-cursor-app
Use run.bat script or
Use next command:
java -jar target/client-cursor-0.0.1-SNAPSHOT.jar \
--spring.datasource.url=jdbc:h2:mem:testdb \
--spring.datasource.username=sa \
--spring.datasource.password=password \
--spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
Use Docker compose:
docker-compose up
http://localhost:9080/articles
http://localhost:9080/swagger-ui.html
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -d '{ "title": "Some tittle", "text": "Some text", "author": { "id": 1 } }' -X POST http://localhost:9080/articles
curl -i http://localhost:9080/articles/1
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -d '{ "title": "Another tittle" }' -X PATCH http://localhost:9080/articles/2
curl -i 'http://localhost:9080/articles?size=2'
Next and prev cursors placed in response: {"data":[...], "prev":..., "next":...}
Use cursor as a parameter in next requests:
curl -i 'http://localhost:9080/articles?size=2&cursor=PUT_NEXT_OR_PREV_CURSOR_HERE'
If needed - add sort
parameter to query, for example sort=title
.
You need to pass it only in initial query, after that all info will be encoded into next/prev cursor and you need to pass cursor only (and size
if needed).
Order direction via order
parameter is supported (ASC
/DESC
)
curl -i -X DELETE http://localhost:9080/articles/1