I have a problem with mapping DB to HTTP Handler. So in Martini framework you can do like this:
// main.go
package main
func main() {
db, err := gorm.Open("mysql", "<user>:<pass>@/mvc_demo")
m := martini.Classic()
m.Map(&db)
m.Run(":3000")
}
// controllers/index.go
package controllers
func IndexGET(w http.ResponseWriter, r *http.Request, *gorm.DB) { ... }
How to do the same with HttpRouter package, because when i parse the variable *gorm.DB, I get an error.