/go-server

very simple API written in go

Primary LanguageGo

go-server

A very simple api written in go. It uses a postgres db to store books. Uses chi web framework to deal with http requests.

Docker

To run the postgres db you will need docker and to create a new volume docker volume create dbgo

Connection string for the db (DBeaver)

jdbc:postgresql://localhost:5432/godb?sslmode=disable&user=gouser&password=admingres

Run go app

go run main.go

How it looks in the terminal

image

API Endpoints

Add a new book from a fake data file

curl -X POST -d @addbook.json -H "Content-Type: application/json" localhost:8080/books

Get all books

image

curl localhost:8080/books

Get a book by id

curl localhost:8080/books/1

Update a book by id

curl -X PUT -d @updatebook.json -H "Content-Type: application/json" localhost:8080/books/1

Delete a book by id

curl -X DELETE localhost:8080/books/1