This repository contains the web app to learn Go REST API development using Mux(Router), JSON Web Token (JWT), and MongoDB.
This is for educational purposes only and probably unsuitable for production
go version go1.12.2
go get [Get all the required packages]
- mux - Request router and dispatcher for matching incoming requests to their respective handler
- mgo - MongoDB driver
- toml - Parse the configuration file (MongoDB server & credentials)
- jwt - JSON Web Tokens (JWT)
- swagger - Swagger Docs
Basic CRUD routes for user management
Show Users GET /api/users
Show User GET /api/users/{userId}
Create User POST /api/users/register
Update User PUT /api/users/{userId}
Delete User DELETE /api/users/{userId}
Verify User GET /api/auth/verify
Login User POST /api/auth/login
Logout User GET /api/auth/logout
Several routes are protected and require JWT tokens, which can be generated using the login route. You will need to create a user by sending a post request to the createUser route.
Database configuration will be done in config.toml file and rest of the configurating of project will be inside the .env file.
$ git clone https://github.com/rajatkeshar/go-api-mongodb-boilerplate.git
$ go get
$ go run *.go
Documentation available at url http://localhost:8080/swagger/index.html
[] Making the code more enhensive and moduler.
[] Implements redisDB for session management.
go-api-mongodb-boilerplate
is licensed under the MIT license. Check the LICENSE file for details.
Rajat Kesharwani <rajat.sunny2@gmail.com>