Skip to content

Instantly share code, notes, and snippets.

@arbarlow
Created April 23, 2015 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arbarlow/d48b71421fba0f7cd6d1 to your computer and use it in GitHub Desktop.
Save arbarlow/d48b71421fba0f7cd6d1 to your computer and use it in GitHub Desktop.
package controllers
import (
"net/http"
"github.com/go-martini/martini"
"github.com/jinzhu/gorm"
"github.com/martini-contrib/render"
. "github.com/madebymany/riru/models"
)
func PhotosControllerRouter(r martini.Router) {
r.Get("", PhotosIndex)
}
func PhotosIndex(r render.Render, db gorm.DB, user User, reel *Reel) {
var photos []Photo;
db.Model(&reel).Related(&photos)
r.JSON(http.StatusOK, photos)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment