Skip to content

adrianrusu/land-routes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LandRoutes Service

Build Status CircleCI Quality Gate Status Coverage Vulnerabilities

This is a simple Spring Boot project that is able to calculate any possible land route from one country to another using JSON parsed data from mledoze/countries loaded at start-time. For every valid request Breadth First Search is used to find the shortest path (the lowest number of other countries) needed to cross when travelling from source to the destination country.

Requirements

For building and running the application you need:

Running the application locally

There are several ways to run a Spring Boot application on your local machine. One way is to execute the main method in the com/adrianr/landroutes/LandRoutesApplication.java class from your IDE.

Alternatively you can use the Spring Boot Maven plugin like so:

mvn spring-boot:run

Building application artefact

The easiest way to build this application is to use the Spring Boot Maven plugin like so:

mvn clean install

This will create:

  • An JAR called "land-routes-0.0.1-SNAPSHOT"

If you want to access run the artefact resulted from the build process, you can use the following command:

java -jar land-routes-0.0.1-SNAPSHOT.jar

Usage

The application starts up and uses port 8080, in order to use it to check the distance between two different countries it exposes an endpoint at:

http://localhost:8080/routing/{source}/{destination}

Replace the following parameters with country codes in ISO 3166-1 alpha-3 format.

  • source
  • destination

Example:

http://localhost:8080/routing/CZE/ITA

Will respond with

Status CodeDescriptionMessage
200 OK
{
  "route": [ "CZE", "AUT", "ITA" ]
}

Exception handling

If any of the country codes are invalid or there is no land path between the two countries then the response status for the request will:.

Status CodeDescriptionMessage
404 NOT FOUND
{
  "timestamp": "2021-11-06T10:11:32.114+00:00",
  "status": 404,
  "error": "Not Found",
  "path": "/routing/ROU/CZEC"
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages