コード例 #1
0
ファイル: main.go プロジェクト: shazow/mog
func GetSource(c context.Context, w http.ResponseWriter, r *http.Request, u *User, g *goon.Goon) (interface{}, error) {
	var ss []*Source
	k := g.Kind(&Source{})
	q := datastore.NewQuery(k).Ancestor(g.Key(u))
	if _, err := g.GetAll(q, &ss); err != nil {
		return nil, err
	}
	ret := make([]*models.Source, len(ss))
	for i, s := range ss {
		ret[i] = &models.Source{
			Protocol: s.Protocol.StringID(),
			Name:     s.ID,
			Blob:     s.Blob,
		}
	}
	return ret, nil
}