An example of a CRUD api in Go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Unbewohnte 81207681fc Set content-type to GET requests, fixed ToJsonAll returning invalid json 3 years ago
dbHandle Set content-type to GET requests, fixed ToJsonAll returning invalid json 3 years ago
logs Rewrite from the ground; SQL database 3 years ago
randomData Set content-type to GET requests, fixed ToJsonAll returning invalid json 3 years ago
.gitignore Now builds, added db to .gitignore 3 years ago
LICENSE Update LICENSE 4 years ago
README.md Removed examples file 3 years ago
go.mod Rewrite from the ground; SQL database 3 years ago
go.sum Now builds, added db to .gitignore 3 years ago
main.go Changed default port to the same as in README, fixed a typo 3 years ago

README.md

CRUD api

A simple CRUD api written in Go

API has implementation of "GET", "POST", "PATCH", "DELETE" http methods, allowing to Read, Create, Update and Delete objects in sqlite3 database via json input.


Status

Implemented:

  • GET
  • POST
  • PATCH
  • DELETE

Examples

  • curl localhost:8000/randomdata - to get EVERYTHING (obviously a bad idea if you have lots of data)
  • curl localhost:8000/randomdata -H "content-type:application/json" -d '{"title":"This is a title","text":"This is a text"}' -X POST - to create a new RandomData (IDs are created automatically from 1-∞)
  • curl localhost:8000/randomdata/1 - to get the first RandomData you`ve created
  • curl localhost:8000/randomdata/1 -H "content-type:application/json" -d '{"title":"This is an updated title","text":"This is an updated text"}' -X PATCH - to update the first RandomData
  • curl localhost:8000/randomdata/1 -X DELETE - to delete the first RandomData

It`s not a recommended or even the correct way of doing a CRUD api of such sort, I'm just practicing