Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ammerzon/mc523-golang-rest
Second exercise for the subject MC523 SS21 at FH OΓ Campus Hagenberg.
https://github.com/ammerzon/mc523-golang-rest
golang microservice postgres postgresql rest
Last synced: about 1 month ago
JSON representation
Second exercise for the subject MC523 SS21 at FH OΓ Campus Hagenberg.
- Host: GitHub
- URL: https://github.com/ammerzon/mc523-golang-rest
- Owner: ammerzon
- Created: 2021-03-29T08:38:04.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-04-29T16:53:40.000Z (over 3 years ago)
- Last Synced: 2023-10-20T16:57:58.940Z (about 1 year ago)
- Topics: golang, microservice, postgres, postgresql, rest
- Language: Go
- Homepage:
- Size: 38.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Microservices in Go
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ammerzon_MC523-golang-rest&metric=alert_status)](https://sonarcloud.io/dashboard?id=ammerzon_MC523-golang-rest) [![Build Status](https://www.travis-ci.com/ammerzon/MC523-golang-rest.svg?branch=main)](https://www.travis-ci.com/ammerzon/MC523-golang-rest)
Second exercise for the subject MC523 SS21 at FH OΓ Campus Hagenberg based on the blog post [Building and Testing a REST API in Go with Gorilla Mux and PostgreSQL](https://semaphoreci.com/community/tutorials/building-and-testing-a-rest-api-in-go-with-gorilla-mux-and-postgresql).
## π Requirements
- `go`
- `docker`
- `docker-compose`
- `skaffold`
- `helm`
- `kubectl`## π Get started
```bash
make run-docker
```## β οΈ Limitations
* This is a demo application and therefore does ignore common security practices.
## βΈοΈ Kubernetes Deployment
Your `kubectl` must be configured correctly. For local deployment [minikube](https://minikube.sigs.k8s.io/docs/) or [Kind](https://kind.sigs.k8s.io/docs/user/quick-start/) can be used.
1. Deploy the application
```bash
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
skaffold run
```2. Forward to a local port
```bash
kubectl port-forward deployment/backend 8010:8010 -n golang-rest
```3. Create the schema and insert test data
## β»οΈ Refactorings
### Folder structure
To blog proposed the following structure:```shell
.
βββ app.go
βββ main.go
βββ main_test.go
βββ model.go
βββ go.sum
βββ go.mod
```The current implementation reorganized the folder structure in the following way and added Docker support:
```shell
.
βββ Dockerfile
βββ cmd
β βββ main.go
β βββ main_test.go
βββ db
β βββ schema.sql
βββ docker-compose.yaml
βββ go.mod
βββ go.sum
βββ internal
βββ config
βββ models
βββ services
```### Features
* Added a product search endpoint (`/search/product`)
* Added a price range filter to the `/product` endpoint
* Added a sort option to the `/product` endpoint