RestAPI-Mongo

command module
v0.0.0-...-30dc2fd Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2020 License: MIT Imports: 6 Imported by: 0

README

RestAPI-Mongo


What it is

A simple and bare minimum Rest API developed using Gorilla Mux and MongoDB. Can be used as an template or reference for future Go project involving RestAPIs.


How to start

Make sure you have Go lang installed

  1. Create a .env file in the root directory of the project
  2. Add MONGO_URL = "mongodb+srv://<MONGO_USER>:<MONGO_PASSWORD>@cluster0.jau8n.mongodb.net/<DEFAULT_DATABASE>?retryWrites=true&w=majority" and use your own MONGO_USER, MONGO_PASSWORD and DEFAULT_DATABASE
  3. go mod tidy
  4. go run main.go

API End Points

  • /person POST - used to add a person to the database, request body should have firstname and lastname
  • /person/{id} GET - used to retrieve a person from database using id
  • /person/{id} DELETE - used to delete a person from database using id
  • /people GET - used to retrieve all records from the people collection

Found Something Broken

If you find something broken or have a suggestion please feel free to open an Issue.


Made with ❤️

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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