github.com/jasonish/buffalo@v0.8.2-0.20170413145823-bacbdd415f1b/examples/hello-world/actions/app.go (about)

     1  package actions
     2  
     3  import (
     4  	"os"
     5  
     6  	"github.com/gobuffalo/buffalo"
     7  	"github.com/gobuffalo/packr"
     8  	"github.com/markbates/going/defaults"
     9  )
    10  
    11  // ENV is used to help switch settings based on where the
    12  // application is being run. Default is "development".
    13  var ENV = defaults.String(os.Getenv("GO_ENV"), "development")
    14  var app *buffalo.App
    15  
    16  // App is where all routes and middleware for buffalo
    17  // should be defined. This is the nerve center of your
    18  // application.
    19  func App() *buffalo.App {
    20  	if app == nil {
    21  		app = buffalo.Automatic(buffalo.Options{
    22  			Env: ENV,
    23  		})
    24  
    25  		app.ServeFiles("/assets", packr.NewBox("../assets"))
    26  		app.GET("/", HomeHandler)
    27  	}
    28  
    29  	return app
    30  }