Documentation ¶
Overview ¶
Package rest is a simple REST interface over MongoDB, as middlware for martini framework
package main
import (
"github.com/go-martini/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.Group("/api/v1", rest.Rest(rest.Config{ Db : db, ResonseField : "data", // optional Autoincrement : true, // optional })) m.Run() }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { // 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.