예제 #1
0
파일: main.go 프로젝트: tylerb/goa
func main() {
	// Create goa service
	service := goa.New("cellar")

	// Setup basic middleware
	service.Use(goa.RequestID())
	service.Use(goa.LogRequest())
	service.Use(goa.Recover())

	// Mount account controller onto service
	ac := controllers.NewAccount(service)
	app.MountAccountController(service, ac)

	// Mount bottle controller onto service
	bc := controllers.NewBottle(service)
	app.MountBottleController(service, bc)

	// Mount Swagger Spec controller onto service
	swagger.MountController(service)

	// Mount JSON Schema controller onto service
	schema.MountController(service)

	// Mount JavaScript example
	js.MountController(service)

	// Run service
	service.ListenAndServe(":8080")
}
예제 #2
0
파일: appengine.go 프로젝트: tylerb/goa
func init() {
	// Configure logging for appengine
	goa.Log.SetHandler(log15.MultiHandler(
		log15.StreamHandler(os.Stderr, log15.LogfmtFormat()),
		AppEngineLogHandler()),
	)

	// Create goa application
	service := goa.New("cellar")

	// Setup CORS to allow for swagger UI.
	spec, err := cors.New(func() {
		cors.Origin("*", func() {
			cors.Resource("*", func() {
				cors.Methods("GET", "POST", "PUT", "PATCH", "DELETE")
				cors.Headers("*")
			})
		})
	})
	if err != nil {
		panic(err)
	}

	// Setup basic middleware
	service.Use(goa.RequestID())
	service.Use(AppEngineLogCtx())
	service.Use(cors.Middleware(spec))
	service.Use(goa.Recover())

	// Mount account controller onto application
	ac := controllers.NewAccount(service)
	app.MountAccountController(service, ac)

	// Mount bottle controller onto application
	bc := controllers.NewBottle(service)
	app.MountBottleController(service, bc)

	// Mount Swagger Spec controller onto application
	swagger.MountController(service)

	// Mount CORS preflight controllers
	cors.MountPreflightController(service, spec)

	// Setup HTTP handler
	http.HandleFunc("/", service.HTTPHandler().ServeHTTP)
}
예제 #3
0
func main() {
	service := goa.New("cfbroker")
	configuration, err := config.Load("./config.yaml")
	if err != nil {
		panic(err)
	}

	store, err := storage.NewLocalFile("/tmp/data")
	if err != nil {
		panic(err)
	}

	provisioningController := controllers.NewProvisioning(store)
	catalogController := commoncontrollers.NewCatalog(configuration.Catalog)

	app.MountCatalogController(service, catalogController)
	app.MountProvisioningController(service, provisioningController)

	swagger.MountController(service)
	service.ListenAndServe(":8080")
}