GoLang, PostgreSQL and Rest API (gorilla/mux package). Very simple examples for inserting, selecting and deleting from PostgreSQL DB using REST APIs.
Installing PostgreSQL on your machine/server should be straight forward. You should be able to find tutorials on google/youtube.
Installing Postman on your machine will allow you to make GET/POST/DELETE and many more requests to your applications.
You will need to get the following packages to make it work:
go get -u github.com/lib/pq
go get -u github.com/gorilla/mux
- Get the 2 packages from above
- Run
go run main.go
- Use Postman to test the requests
- Get all books - [GET] http://localhost:8000/books/
- Create a book - [POST] http://localhost:8000/books/ - (body: 'x-www-form-urlencoded', pass in bookid and bookname)
- Delete a book by bookid - [DELETE] http://localhost:8000/books/{bookid} - make sure to use a valid bookid from books table (bookid not id)
- Delete all books - [DELETE] http://localhost:8000/books/
CREATE TABLE books (
id SERIAL PRIMARY KEY,
bookid character varying(50) NOT NULL,
bookname character varying(255) NOT NULL
);
More information about building Rest APIs using gorilla/mux package (https://github.com/gorilla/mux):