Documentation ¶
Overview ¶
Package rest is a simple REST interface over MongoDB, as middlware for martini framework
package main import ( "github.com/codegangsta/martini" "labix.org/v2/mgo" "github.com/olebedev/rest" ) func main() { session, err := mgo.Dial("localhost") if err != nil { panic(err) } defer session.Close() session.SetMode(mgo.Monotonic, true) db := session.DB("test") m := martini.Classic() m.Use(rest.Serve(&rest.Config{ Prefix: "/api/v1", Db: db, ResonseField: "data", // optional })) m.Run() }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { // API prefix for routing it right. Prefix string // Mongo instance pointer. Db *mgo.Database // Optional response field name. It is necessary to obtain the expected response. ResonseField string // Use integer autoincrement for _id instead of mongodb auto generated hash Autoincrement bool }
Config is a struct for specifying configuration options for the rest.Rest middleware.
Click to show internal directories.
Click to hide internal directories.