Skip to content

l4rma/go-rest-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Restfull API written in GO

Me trying to learn golang by coding a rest api with clean archetecture following the SOLID principles. So far I've refactored and extracted all dependencies and implemented interfaces so that its easy to swap out db (postgres) and routing (gorilla/mux). Then added SQLite as a DB which I (will) use for testing.

Status:

  • "/" => "Hello world!"
  • Serve static page
  • Serve some static pages (home, errors)
  • Database (postgres in docker)
  • GET request (get all)
  • GET request (get by id)
  • POST request
  • Cleaner archetecture
  • Tests (service layer)
  • Dockerfile
  • docker-compose
  • Improove README.md
  • Add comments to code
  • Tests (controller) - in progress
  • Alternative DB (SQLITE) - in progress
  • PUT request
  • PATCH request
  • DELETE request
  • MOAR Tests!
  • Implement swagger
  • Add Authorization

How to use:

Run db and server in docker with docker-compose:

docker-compose up

Testing with curl:

Get all books:

curl localhost:8080/api/books

Get book with id = 1:

curl localhost:8080/api/books/1

Create a book:

curl localhost:8080/api/books -H "application/json" -d '{"title":"<title>","author":"<author>", "year": 2022}' -X POST

Delete a book with id = 1:

curl localhost:8080/api/books/delete/1 -X DELETE

About

A RestApi written in GO

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages