Web application having CRUD operations under customer object
- Go language
- PostgreSQL DB
- HTML
- CSS
- JS
- Bootstrap 4
- github.com/gorilla/mux
- github.com/lib/pq
- host: localhost
- port: 5432
- user: martin
- password: qweasdzxc
- DB name: application
CREATE TABLE customers (
id SERIAL PRIMARY KEY,
first_name VARCHAR(100) NOT NULL,
last_name VARCHAR(100) NOT NULL,
birth_date TIMESTAMP NOT NULL,
gender VARCHAR(10) NOT NULL,
email VARCHAR(100) UNIQUE NOT NULL,
address VARCHAR(200)
);
INSERT INTO customers(
first_name,
last_name,
birth_date,
gender,
email,
address
)
VALUES (
'Test',
'Tester',
'2016-06-22 19:10:25',
'Male',
'[email protected]',
'Test City address'
);
-
(MODELS folder) The models package will store the database schema. Using struct type to represent or map the database schema in golang.
-
(MIDDLEWARE folder) The middleware package is the bridge between APIs and Database. This package will handle all the db operations like Insert, Select, Update, and Delete (CRUD).
-
(ROUTER folder) In the router package defines all the api endpoints.
-
(MAIN file) The main.go is server. It will start a server on 8080 port and serve all the Router.
- localhost:8080/customers, GET ALL CUSTOMERS ( GET )
- localhost:8080/customer/{id}, GET CUSTOMER ( GET )
- localhost:8080/customer/create, CREATE CUSTOMER ( POST )
- localhost:8080/customer/{id}/update, UPDATE CUSTOMER BY ID ( PUT )
- localhost:8080/customer/{id}/delete, DELETE CUSTOMER BY ID ( DELETE )