A Rest API that manage delivery routes
// Welcome method
GET /routes/index
// Get all routes
GET /routes/
// Get route from origin_point to destination_point
GET /routes/{origin_point}/to/{destination_point}
// Insert sample data
POST /routes/
// Add route from origin_point to destination_point
POST /routes/{origin_point}/to/{destination_point}
// Update route from origin_point to destination_point
PUT /routes/{origin_point}/to/{destination_point}
// Delete route from origin_point to destination_point
DELETE /routes/{origin_point}/to/{destination_point}
// Welcome method
GET /points/index
// Get all points
GET /points/
// Get point with name
GET /points/{name}
// Add point with name
POST /point/{name}
// Update point with name
PUT /points/{name}
// Delete point with name
DELETE /points/{name}
GET /routes/a/to/b
{
"origin": {
"id": 1,
"name": "A"
},
"destination": {
"id": 2,
"name": "B"
},
"paths": {
"paths": [
{
"origin": {
"id": 1,
"name": "A"
},
"destination": {
"id": 3,
"name": "C"
},
"time": 900,
"cost": 20
},
{
"origin": {
"id": 3,
"name": "C"
},
"destination": {
"id": 2,
"name": "B"
},
"time": 900,
"cost": 12
},
{
"origin": {
"id": 1,
"name": "A"
},
"destination": {
"id": 5,
"name": "E"
},
"time": 30,
"cost": 5
},
{
"origin": {
"id": 1,
"name": "A"
},
"destination": {
"id": 4,
"name": "H"
},
"time": 10,
"cost": 1
},
{
"origin": {
"id": 4,
"name": "H"
},
"destination": {
"id": 5,
"name": "E"
},
"time": 30,
"cost": 1
},
{
"origin": {
"id": 5,
"name": "E"
},
"destination": {
"id": 6,
"name": "D"
},
"time": 3,
"cost": 5
},
{
"origin": {
"id": 6,
"name": "D"
},
"destination": {
"id": 7,
"name": "F"
},
"time": 4,
"cost": 50
},
{
"origin": {
"id": 7,
"name": "F"
},
"destination": {
"id": 8,
"name": "I"
},
"time": 45,
"cost": 50
},
{
"origin": {
"id": 7,
"name": "F"
},
"destination": {
"id": 9,
"name": "G"
},
"time": 40,
"cost": 50
},
{
"origin": {
"id": 8,
"name": "I"
},
"destination": {
"id": 2,
"name": "B"
},
"time": 65,
"cost": 5
},
{
"origin": {
"id": 9,
"name": "G"
},
"destination": {
"id": 2,
"name": "B"
},
"time": 64,
"cost": 73
}
],
"pathCount": 11
},
"shortestPath": "A-E-D-F-G-B"
}
For authentication i used the basic method, the user and password were hardcoded(for simplication) and are:
- User: admin
- Password: qwerty
Authorization header:
Authorization: Basic YWRtaW46cXdlcnR5
For persistence i used H2 database(in memory mode), so no ddl or sql script is needed for deployment.
After the dependencies were met, for test the solution, you need follow these steps:
- Go to project folder
- Run gradle test (NOTE: There are ignored tests)
After the dependencies were met, for run the solution, you need follow these steps:
- Go to project folder
- Run gradle bootRun
- Open a rest client(like postman) and perform a request to http://localhost:9000/routes/index or http://localhost:9000/points/index
After the dependencies were met, for compile the solution, you need follow these steps:
- Go to project folder
- Run gradle bootJar
- Go to build/libs to take the jar created recently
NOTE: There is one jar attached at release section for this repository
$> java -jar deliveryservice-1.0.jar # Default port is 9000
or
$> java -jar -Dserver.port=SERVER_PORT deliveryservice-1.0.jar