github.com/corylanou/buffalo@v0.8.0/generators/newapp/templates/actions/app.go.tmpl (about) 1 package actions 2 3 import ( 4 "github.com/gobuffalo/buffalo" 5 {{ if .withPop }} 6 "github.com/gobuffalo/buffalo/middleware" 7 "{{.modelsPath}}" 8 {{ end }} 9 "github.com/gobuffalo/envy" 10 "github.com/gobuffalo/packr" 11 ) 12 13 // ENV is used to help switch settings based on where the 14 // application is being run. Default is "development". 15 var ENV = envy.Get("GO_ENV", "development") 16 var app *buffalo.App 17 18 // App is where all routes and middleware for buffalo 19 // should be defined. This is the nerve center of your 20 // application. 21 func App() *buffalo.App { 22 if app == nil { 23 app = buffalo.Automatic(buffalo.Options{ 24 Env: ENV, 25 SessionName: "_{{.name}}_session", 26 }) 27 28 {{ if .withPop }} 29 app.Use(middleware.PopTransaction(models.DB)) 30 {{ end }} 31 32 app.GET("/", HomeHandler) 33 34 app.ServeFiles("/assets", packr.NewBox("../public/assets")) 35 } 36 37 return app 38 }