Exemple #1
0
// main takes care of how to run when called via the CLI
func main() {
	// Add MongoDB flags to the parser
	flag.StringVar(&conf.Config.MongoURI, "MongoURI", conf.Config.MongoURI, "MongoDB server URI")
	flag.StringVar(&conf.Config.MongoDatabase, "MongoDatabase", conf.Config.MongoDatabase, "MongoDB database")

	// Make a new server.
	server := goserv.NewServer(&conf.Config.BaseConfiguration)
	wsContainer := restful.NewContainer()
	p := api.Product{}
	p.Register(wsContainer)

	status := api.StatusResource{}
	status.Register(wsContainer)

	groups := api.GroupsResource{}
	groups.Register(wsContainer)

	hash := api.HashResource{}
	hash.Register(wsContainer)

	coordinates := api.CoordinatesResource{}
	coordinates.Register(wsContainer)

	wsContainer.ServiceErrorHandler(api.ErrorHandler)

	// Set the handler to our gorilla mux router wrapped with LogAccess
	server.Handler = goserv.LogAccess(wsContainer)
	goserv.Logger.Fatal(server.ListenAndServe())
}
Exemple #2
0
// main takes care of how to run when called via the CLI
func main() {
	// Add MongoDB flags to the parser
	flag.StringVar(&conf.Config.MongoURI, "MongoURI", conf.Config.MongoURI, "MongoDB server URI")
	flag.StringVar(&conf.Config.MongoDatabase, "MongoDatabase", conf.Config.MongoDatabase, "MongoDB database")

	// Make a new server.
	server := goserv.NewServer(&conf.Config.BaseConfiguration)
	wsContainer := restful.NewContainer()
	p := api.Product{}
	p.Register(wsContainer)

	status := api.StatusResource{}
	status.Register(wsContainer)

	groups := api.GroupsResource{}
	groups.Register(wsContainer)

	hash := api.HashResource{}
	hash.Register(wsContainer)

	wsContainer.ServiceErrorHandler(api.ErrorHandler)

	// Enable swagger
	/*config := swagger.Config{
		WebServices: wsContainer.RegisteredWebServices(),
		ApiPath:     "/service/v3/apidocs.json",
	}
	swagger.RegisterSwaggerService(config, wsContainer)
	*/
	// Set the handler to our gorilla mux router wrapped with LogAccess
	server.Handler = goserv.LogAccess(wsContainer)
	goserv.Logger.Fatal(server.ListenAndServe())
}