skyikho / mongodm-example

A simple JSON REST API as an example project for https://github.com/zebresel-com/mongodm/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Example API for mongodm

This is an example REST API for the mongodm package written in golang with use of the beego web framework. To simplify response/error handling the beego-response package is also included as an example.

There are two controllers (User and Message) where you can create and get something.

You will find an implementation for

  • Connection setup
  • Models
  • Model registration
  • Model creation (persisting/saving)
  • Population
  • Relations (1:1, 1:N)
  • Querys (Find, FindOne, ..)
  • Custom validation
  • Default validation
  • Localisation example
  • Response-/Error-Handling
  • Pagination
  • Using namespaces, routers and filters with beego
  • Dealing with a "Base-Controller" in beego

You won`t find an implementation for

  • Model updating
  • Model deleting
  • Authentication

Maybe I will add the missing points later..

Requirements

  • golang setup
  • a mongo database (by now password authentication is not supported)
  • some REST client for testing (optional)
  • beego package go get github.com/astaxie/beego
  • mongodm package go get github.com/zebresel-com/mongodm
  • beego-response package go get github.com/zebresel-com/beego-response

Quickstart

Move to your project directory and run go build; ./mongodm-sample (Unix) and beego should start the webserver on port 8080 for you. You can change beego settings in conf/app.conf, if necessary. To find all implemented and available REST endpoints open up apidoc/index.html in your browser. Thats all, you can test now!

Feel free to contribute!

Ask if you think that there is something missing.

About

A simple JSON REST API as an example project for https://github.com/zebresel-com/mongodm/

License:MIT License


Languages

Language:JavaScript 46.4%Language:HTML 25.3%Language:Go 18.9%Language:CSS 9.4%