예제 #1
0
파일: unico.go 프로젝트: licio/unico
func init() {
	// Read configuration file
	content, err := ioutil.ReadFile("config.json")
	if err == nil {
		err = json.Unmarshal(content, &appConfig)
	}
	if err != nil {
		panic("Can't load configuration")
	}

	// Make sure every conf option has been completed, except
	// for AppDomain, because it is useful to test the app with
	// localhost but some browsers require localhost cookies
	// to have Domain as ""
	if appConfig.FacebookAppId == "" || appConfig.FacebookAppSecret == "" ||
		appConfig.GoogleClientId == "" || appConfig.GoogleClientSecret == "" ||
		appConfig.TwitterConsumerKey == "" || appConfig.TwitterConsumerSecret == "" ||
		appConfig.AppHost == "" ||
		appConfig.SessionStoreKey == "" {
		panic("Invalid configuration")
	}

	// Register the datastore and memcache session stores.
	sessions.SetStore("datastore", new(appengineSessions.DatastoreSessionStore))
	sessions.SetStore("memcache", new(appengineSessions.MemcacheSessionStore))

	// Set secret keys for the session stores.
	sessions.SetStoreKeys("datastore", []byte(appConfig.SessionStoreKey))
	sessions.SetStoreKeys("memcache", []byte(appConfig.SessionStoreKey))

	http.HandleFunc("/", homeHandler)
	http.HandleFunc("/twitter", twitterHandler)
	http.HandleFunc("/loginGoogle", loginGoogle)
	http.HandleFunc("/oauth2callback", googleCallbackHandler)
	http.HandleFunc("/fb", fbHandler)
	http.HandleFunc("/sync", syncHandler)
	http.HandleFunc("/deleteAccount", deleteAccountHandler)
	http.HandleFunc("/deleteFacebook", deleteFacebookHandler)
	http.HandleFunc("/deleteTwitter", deleteTwitterHandler)

}
예제 #2
0
파일: hello.go 프로젝트: ashokgelal/gorilla
func init() {

	// Register a couple of routes.
	router.HandleFunc("/", homeHandler).Name("home")
	router.HandleFunc("/{salutation}/{name}", helloHandler).Name("hello")
	router.HandleFunc("/memcache-session", memcacheSessionHandler).Name("memcache-session")
	router.HandleFunc("/datastore-session", datastoreSessionHandler).Name("datastore-session")

	// Send all incoming requests to router.
	http.Handle("/", router)

	// Register the datastore and memcache session stores.
	sessions.SetStore("datastore", new(appengineSessions.DatastoreSessionStore))
	sessions.SetStore("memcache", new(appengineSessions.MemcacheSessionStore))

	// Set secret keys for the session stores.
	sessions.SetStoreKeys("datastore",
		[]byte("my-secret-key"),
		[]byte("1234567890123456"))
	sessions.SetStoreKeys("memcache",
		[]byte("my-secret-key"),
		[]byte("1234567890123456"))
}