go get github.com/shamlikt/simpleHTTPLoginServer
- Create mysql table as below, CREATE TABLE `users` ( `id` int(6) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(100) NOT NULL UNIQUE, `password` varchar(100) NOT NULL, `email` varchar(50) NOT NULL, `age` int(6) NOT NULL, `salary` int(100) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
- All config are stored in a yaml file
- change
system_config.yaml
as per the mysql connection parameters
- we need to pass the config as command line parameter as given below,
simpleHTTPLoginServer -c system_config.yaml
method: POST
curl -v --header "Content-Type: application/json" --request POST --data '{"username":"test","password":"test", "age":10 , "salary":10000, "email":"test@mail.com"}' http://localhost:9000/signup
Response: { “Status”: true, “Message”: “User Added successfully” }
method: POST
curl -v --header "Content-Type: application/json" --request POST --data '{"username":"test","password":"test"}' http://localhost:9000/login
Response: { “Status”: true, “Message”: “User Authenticated successfully”, “Token”: “<token>” }
Need to pass token as Auth-token
header
method: GET
curl -H"Authorization: BEARER <token>" -v http://localhost:9000/data
Response: { “data”: { “username”: “test”, “password”: “”, “email”: “test@mail.com”, “age”: 10, “salary”: 10000 }, “status”: true, “message”: “Got user information ” }
- unit test
- swagger doc