github.com/iron-io/functions@v0.0.0-20180820112432-d59d7d1c40b2/examples/blog/routes/post_list.go (about)

     1  package route
     2  
     3  import (
     4  	"github.com/iron-io/functions/examples/blog/database"
     5  	"gopkg.in/mgo.v2/bson"
     6  )
     7  
     8  func HandlePostList(db *database.Database, auth map[string]interface{}) {
     9  	posts, err := db.GetPosts([]bson.M{})
    10  	if err != nil {
    11  		SendError("Couldn't retrieve posts")
    12  		return
    13  	}
    14  
    15  	SendResponse(Response{
    16  		"posts": posts,
    17  	})
    18  }