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.
- 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
- Model updating
- Model deleting
- Authentication
Maybe I will add the missing points later..
- 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
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.