Пример #1
0
func main() {
	api := api2go.NewAPI("v1")
	api.SetRedirectTrailingSlash(false)

	api.AddResource(model.Author{}, &controller.Author{})
	api.AddResource(model.Blog{}, &controller.Blog{})
	api.AddResource(model.Book{}, &controller.Book{})

	http.ListenAndServe(":3000", api.Handler())

}
Пример #2
0
//BootstrapAPI blub
func BootstrapAPI(config *bongo.Config) http.Handler {
	api := api2go.NewAPI("v1")
	connection, err := bongo.Connect(config)
	defer connection.Session.Close()

	if err != nil {
		log.Fatal(err)
	}

	api.AddResource(User{}, UserSource{connection: connection})

	return api.Handler()
}