mgo-n-goji

module
v0.0.0-...-5cca3c0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2019 License: ISC

README

mgo-n-goji

Pre-requisites

⚫ go ⚫ mongoDB ⚫ node

Installing

Clone it and then run

cd $GOPATH/src && git clone https://github.com/immontilla/mgo-n-goji.git
cd $GOPATH && go install mgo-n-goji/cmd/app/
Testing

To test, I am going to use Postman and its client Newman. To show the results, I'll use express and newman-reporter-html.

cd $GOPATH/src/mgo-n-goji/tests/postman/ && npm install && npm run test-n-report
Running
$GOPATH/bin/app
  • Add bob as a contact. His mobile is 600000001.
curl -iX POST "http://localhost:9889/contacts" -H "Content-Type: application/json" -d "{\"nick\":\"bob\",\"mobile\":[\"600000001\"]}" && echo ""
  • Get bob's contact data
curl -iX GET "http://localhost:9889/contacts/bob" && echo ""
  • Get all contacts so far
curl -iX GET "http://localhost:9889/contacts" && echo ""
  • Update bob's contact data
curl -iX PUT "http://localhost:9889/contacts/bob" -H "Content-Type: application/json" -d "{\"nick\":\"bob\",\"mobile\":[\"600000001\"],\"email\":[\"bob@email.us\"]}" && echo ""
  • Add mobile 600000002 to a bob
curl -iX PATCH "http://localhost:9889/contacts/bob/addMobile/600000002"  && echo ""
  • Remove mobile 600000001 from bob
curl -iX PATCH "http://localhost:9889/contacts/bob/delMobile/600000001"  && echo ""
curl -iX PATCH "http://localhost:9889/contacts/bob/addEmail/bob2@email.us"  && echo ""
curl -iX PATCH "http://localhost:9889/contacts/bob/delEmail/bob@email.us"  && echo ""
  • Change bob nick to bobby
curl -iX PATCH "http://localhost:9889/contacts/bob/newNick/bobby"  && echo ""
  • Delete bobby
curl -iX DELETE "http://localhost:9889/contacts/bobby"  && echo ""

Directories

Path Synopsis
cmd
app
pkg

Jump to

Keyboard shortcuts

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