Skip to content

mohokh67/REST-with-Go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Endpoints

  • [GET] /
  • [GET, POST, HEAD, OPTIONS] /organisation/accounts
  • [GET, DELETE, HEAD, OPTIONS] /organisation/accounts/{accountId}

Create a new account example:

  • [POST] /organisation/accounts/
    • Headers:

      "Content-Type": "application/vnd.api+json"

    • Body

{
    "type": "accounts",
    "version": 0,
    "attributes": {
        "country": "GB",
        "base_currency": "GBP",
        "account_number": "41426819",
        "bank_id": "400300",
        "bank_id_code": "GBDSC",
        "bic": "NWBKGB22",
        "iban": "GB11NWBK40030041426819",
        "name": "MoHo Khaleqi",
        "title": "Mr",
        "account_classification": "Personal",
        "joint_account": false,
        "status": "confirmed"
    }
}

Extras

  • HEAD HTTP method has been added just as a good practice for the purpose of resource availability and to reduce the cost of expensive requests.

  • OPTIONS HTTP methods has been added to give more information to the end user for available options.

Pagination

Pagination is available through page_number and page_size parameters. e.g. "/organisation/accounts?page_number=1&page_size=2" Default page_size for the list of accounts is 100.

Third party libraries: In this project I used the Google UUID for ID creations and also storm for DB creation. By using them, there is no generated code or anything which made the process automated in general. (As you will see in the source code).

Database: All data is saved to the account.db file as a database for simplicity. For the purpose of this task, a memory based solution also could work.

Routing: There are better libraries to compare net/http's default ServeMux, which is very limited and does not have especially good performance. In the real world projects maybe the httprouter would be a better solution.

I tried Convey which seems to be good enough and easy. Also I tried Ginkgo with BDD pattern. I found these two almost good. However there should be more research on them on my side.

Apart from health checks which should be done on a regular basis on the API for monitoring down time, availability; a good set of end to end tests could also give us more confidence. Unit tests and functional tests are playing an important role here too.

The project could run with go run ./scripts/main.go . Tests result could be seen by running this command go test -v ./...

Releases

No releases published

Packages

No packages published

Languages