Skip to content

olliebatch/postcode_api_rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

postcode_api_rust

This is a basic rust api that takes in a postcode and provides a longitude and latitude for a given postcode.

Installation

In order to install the package you can clone the repo onto your local machine.

You will need to add an .env file, the .env.example can provide some basic setup.

When you run the api it will install the relevant packages for you.

Usage

In order to start running the project you can run which will start the api if you've followed the steps of installation.

cargo run



In order to run the tests for the api you can run:

cargo test

Routes

There are three routes provided on this api: I'd recommend using postman but curl requests are also provided below.

GET - "/healthz" -health check
GET - "/postcode/{postcode goes here}" -singular postcode search


curl --location --request GET 'http://localhost:8080/postcode/WC2N 5DU'

POST - "/postcodes" for multiple post codes

curl --location --request POST 'http://localhost:8080/postcodes' \ --header 'Content-Type: application/json' \ --data-raw '["OX49 5NU", "M32 0JG", "NE30 1DP"]'



Raw data for a postman request:

["OX49 5NU", "M32 0JG", "NE30 1DP"]



Improvements to be made

If I had further time -
Add better Error handling, for now it only returns 500 responses if any problems, which is not ideal in this scenario. Internally we have some errors but these need to be mapped into a Tide Error Response. To get that data out.

I would have implemented further testing by introducing further mock postcode clients.
An OAS Swagger spec so that it is easily callable and visible to see specs.
Further clients to get different postcode data such as weather.

I think a GQL server would be useful here instead of REST. Especially if you chain more and more info onto the postcode info.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published