Skip to content

tadovas/go-flight-sort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flight path calculation microservice

Given list of user direct flights as input, service calculates initial and final destinations if possible.

To run service

go run cmd/main.go

It will start serving http requests at 8080 port

API documentation

POST /calculate

Request

Expected Content-type: application/json

Expects json body with single field flights which contains list of users flights. Example:

{
    "flights": [
        {
            "source": "ATL",
            "dest": "EWR"
        }, { 
            "source": "SFO", 
            "dest": "ATL"
        }
    ]
}

Each flight object consists of source and dest airports.

Response

Content-type: application/json

A json object containing single flight field with initial source and final destination airports for given user input. Example:

{
    "flight": {
        "source": "SFO",
        "dest": "EWR"
    }
}

Service errors

In case of http code other than 200 OK, Service returns generic error json object with single field error of string type with error description and appropriate http error code. Example:

{
    "error": "input sanitization: flights[0] source is empty"
}
Http error codes
Http code Description
200 Everything went well. Normal response with flight should be present
405 Only HTTP POST method is allowed
415 Only application/json body is allowed
400 Cannot parse JSON body
422 Either input validation failed or flight sorting function returned error

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages