Skip to content

qvest-digital/spring-boot2-sample-webflux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot 2 Sample Webflux Application

This is a sample application using Spring Boot 2 with Spring Webflux.

Getting stated

JDK 9

In order to get started with this sample application you need to install JDK 9. You can use SDKMAN! for that if you want.

MongoDB

The application need a running MongoDB instance, the easiest way to start one, is through docker

docker run --name some-mongo mongo

Then you need to get the IP address of the mongo container

docker inspect --format '{{ .NetworkSettings.IPAddress }}'  some-mongo

If the IP address is not 172.17.0.2, then you must change the IP address specified in the file src/main/resources/application-local.yml under the key spring.data.mongodb.host

spring:
  data:
    mongodb:
      host: 172.17.0.2

Start the application

In order to start the sample application just call

./gradlew bootRun

or on Windows

./gradlew.bat bootRun

IDE

You can use an IDE to look at the source code, I recommend the Spring Tool Suite, but you use any IDE that you see fit.

Example requests

These example requests are issued through HTTPie.

GET a list of customers
http -v -a user:user :8080/customers/
GET a list of customers with paging
http -v -a user:user :8080/customers/ size==2 page==1
GET a customer by id
http -v -a user:user :8080/customers/5acb629d859c16689db5f091
CREATE a customer
http -v -a admin:admin POST :8080/customers/ firstName=Daenerys lastName=Targaryen
DELETE a customer by id
http -v -a admin:admin DELETE :8080/customers/5ae2ef2a7593241a65e2b961
Stream customers
http --stream -v -a user:user :8080/customers/stream 'Accept: text/event-stream'