github.com/wawandco/ox@v0.13.6-0.20230809142027-913b3d837f2a/plugins/tools/ox/app/templates/app.go.tmpl (about)

     1  package app
     2  
     3  import (
     4  	"github.com/gobuffalo/buffalo"
     5  	"github.com/gobuffalo/envy"
     6  )
     7  
     8  var (
     9  	root  *buffalo.App
    10  )
    11  
    12  // App creates a new application with default settings and reading 
    13  // GO_ENV. It calls setRoutes to setup the routes for the app that's being
    14  // created before returning it
    15  func New() *buffalo.App {
    16  	if root != nil {
    17  		return root
    18  	}
    19  
    20  	root = buffalo.New(buffalo.Options{
    21  		Env:         envy.Get("GO_ENV", "development"),
    22  		SessionName: "_{{.Name}}_session",
    23  	})
    24  
    25  	// Setting the routes for the app
    26  	setRoutes(root)
    27  
    28  	return root
    29  }