Rest-api using spring boot
Java
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
README.md
pom.xml

README.md

This is a simple rest-api written with the Spring Boot Java framework. It returns cities/locations within a radius specified by latitude and longitude in json-format.

Example, find locations within 250 km. of Berlin, Germany. Time measured is after reboot and only one run.

$ time curl -s http://localhost:8080/cities/52.516666/13.4/250 > /dev/null
curl -s http://localhost:8080/cities/52.516666/13.4/250 > /dev/null 0.01s user 0.01s system 1% cpu 1.705 total

The GET-request is then cached using caffeine and returned much faster.

$ time curl -s http://localhost:8080/cities/52.516666/13.4/250 > /dev/null
curl -s http://localhost:8080/cities/52.516666/13.4/250 > /dev/null 0.01s user 0.01s system 21% cpu 0.073 total

How many locations did we find?

$ curl -s http://localhost:8080/cities/52.516666/13.4/250 |grep -o name_|wc -l
27896

Approx. 4.1 MB of json-data is returned.

$ curl -s http://localhost:8080/cities/52.516666/13.4/250 |wc
0 7477 4344434

It is a rewrite of jooby-worldcities except the import-part. It uses postgresql as database, maven as build-system and JDK 8. If you want you can download a dump of the database with approx. 3.1 mill. records and import it. Create a database with the user worldcitites as owner and import it.

You can run the program from the command line using "mvn spring-boot:run" and connect to http://localhost:8080.