Let's learn some Golang with a simple REST API microservice.
Implemented using chi for routing, bbolt for data persistance, swagger for sdk and ui generation, testify for testing.
Since this is a very simple microservice, there wasn't much architecture needed. There is just one simple resource managed. Below is a simple high level diagram describing the architecture.
________ _________ __________
ClientApplication [SDK] ------------- | | | | | |
< HTTP > | HTTP | | Message | | Database |
ClientApplication [SDK] ------------- | Server | -- | Service | -- | |
|________| |_________| |__________|
"/messages" |
"/messages/{messageId}" |
|
|
Web Browser ------------------------------
"/swagger"
The RESTful API is described in an OpenAPI 3.0 document found here: (openapi.json)
usage: ./rest-api-microservice-demo db_path [port] [db_bucket_name]
go test ./...