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) }
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")) }