예제 #1
0
func init() {
	// Mongo URL
	url, ok := config.GroupString("db", "mongoURL")
	if !ok {
		log.Fatal("wombat:apps:article: MongoURL missing from configuration")
	}

	// Database name
	db, ok := config.GroupString("db", "mongoDB")
	if !ok {
		db = "main"
	}

	col, ok := config.GroupString("db", "mongoCol")
	if !ok {
		col = "articles"
	}

	// Mongo error
	b, err := New(url, db, col)
	if err != nil {
		log.Fatal("Failed to create backend: %v", err)
	}

	// Register
	backends.Register("wombat:apps:article-reader", b)
	backends.Register("wombat:apps:article-printer", b)
}
예제 #2
0
파일: mongo.go 프로젝트: juztin/wombat
func init() {
	if url, ok := config.GroupString("db", "mongoURL"); !ok {
		log.Fatal("users mongo: MongoURL missing from configuration")
	} else if session, err := mgo.Dial(url); err != nil {
		log.Fatal("Failed to retrieve Mongo session: ", err)
	} else {
		// set monotonic mode
		session.SetMode(mgo.Monotonic, true)
		// register backend
		b := Backend{session}
		backends.Register("mongo:user-reader", b)
		backends.Register("mongo:user-writer", b)
	}

	if d, ok := config.GroupString("db", "mongoDB"); ok {
		db = d
	}
}
예제 #3
0
func ExampleGroupString() {
	// for a `config.json` file like:
	/*
		{
			"host": "google.com",
			"links": {
				"google": "https://google.com"
			}
		}
	*/
	groupHost, ok := config.GroupString("links", "google")
	fmt.Println(groupHost, ok)
	// Output:
	// https://google.com true
}
예제 #4
0
파일: config.go 프로젝트: juztin/wombat
func setString(group, key string, s *string) {
	if v, ok := config.GroupString(group, key); ok {
		*s = v
	}
}