Giter VIP home page Giter VIP logo

go-demo-api's Introduction

Tasks

Create a new Go application that does the following:

  • Runs as a daemon on the command line- Structure the program so that it can be expanded for more routes and become a larger application, even though we're only going to put two routes in it for this test.
  • Uses MongoDB as a database with an accounts collection
  • Exposes port 80 and provides an HTTP REST interface
  • Provides a /create_account route that takes an HTTP POST with JSON body that contains an email address and password and creates a document in the accounts collection of the DB with the email and password
  • Ensure the password is stored securely in the database
  • Provides an /authenticate route that takes an HTTP POST with a JSON body that contains an email address and password and authenticates it vs a stored account. Returns an HTTP 200 if successful or an HTTP 401 if not successful.
  • Should handle errors and return 400's
  • Should log nicely to the console
  • Should have tests

Usage

  -p int
        Server port (default 80)
  -password string
        Mongo Database password (default "root")
  -user string
        Mongo Database user (default "root")

Notes

80 port is priveleged port and can be opened by root. So by default use another port

Tests

Run a server

go test

If server uses another port, use -p argument to define the port

$ go test -v -args -p 4488

go-demo-api's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.