go-api-mongodb-boilerplate

command module
v0.0.0-...-a214acc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2019 License: MIT Imports: 7 Imported by: 0

README

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

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>

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
controllers
api
lib

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL