Skip to content

adarshaJha/go-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoLang Restful API Boilerplate (Mux, JWT, MongoDB)

This repository contains the web app to learn Go REST API development using Mux(Router), JSON Web Token (JWT), and MongoDB.

Instructions

This is for educational purposes only and probably unsuitable for production

Install Go Programming language latest version

N|Solid

Support version

go version go1.12.2

To get basic external modules for REST API

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

What's included

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.

Configuration

Database configuration will be done in config.toml file and rest of the configurating of project will be inside the .env file.

To get this repository and run

$ git clone https://github.com/rajatkeshar/go-api-mongodb-boilerplate.git
$ go get
$ go run *.go

Swagger documentation

Documentation available at url http://localhost:8080/swagger/index.html

Todos

[] Making the code more enhensive and moduler.
[] Implements redisDB for session management.

License

go-api-mongodb-boilerplate is licensed under the MIT license. Check the LICENSE file for details.

Author

Rajat Kesharwani <rajat.sunny2@gmail.com>

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published