Skip to content

shamlikt/simpleHTTPLoginServer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Login server

Install

Install go packages

go get github.com/shamlikt/simpleHTTPLoginServer

Create table
  • 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;
Change config
  • All config are stored in a yaml file
  • change system_config.yaml as per the mysql connection parameters

Run

  • we need to pass the config as command line parameter as given below,
  • simpleHTTPLoginServer -c system_config.yaml

Api

Create new user

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” }

Login user

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>” }

Get Info

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 ” }

Need to add

  • unit test
  • swagger doc

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages