This API is designed to calculate the route with the flights list provided. VolumeFi take home solution.
To run the application, follow these steps:
- Clone the repository to your local machine.
- Open the terminal and navigate to the root directory of the project.
- Run the following command to start the application:
go run cmd/main.go
- The server will start and the application will be ready to accept requests on
localhost:8080
.
To make a request to the API, use the following curl
command:
curl --request POST \
--url http://localhost:8080/calculate \
--header 'Content-Type: application/json' \
--data '{
"flights": [["IND", "EWR"], ["SFO", "ATL"], ["GSO", "IND"], ["ATL", "GSO"]],
"route": [["SFO", "EWR"]]
}'
The above command will make a POST request to the calculate
endpoint of the API running on http://localhost:8080
. The request body should be a JSON object with two keys: flights
and route
. The flights
key should have an array of flight lists in the format ["from_airport_code", "to_airport_code"]
, and the route
key should have an array of two airport codes in the format ["origin_airport_code", "destination_airport_code"]
.
The API will respond with a JSON object containing the calculated route.