Example #1
0
// GET connect to DB
func Connect(w http.ResponseWriter, r *http.Request, c *webc.Context) {
	var connection map[string]string
	if config.GetAs("connections", c.GetPathVar("db"), &connection) {
		if address, ok := connection["address"]; ok && address != "" {
			if rpc.Connect(address, connection["token"]) {
				c.SetFlash("alertSuccess", "Successfully connected to database")
				c.Set("db", c.GetPathVar("db"))
				http.Redirect(w, r, "/", 303)
				return
			}
		}
	}
	c.SetFlash("alertError", "Error connecting to the database")
	http.Redirect(w, r, "/", 303)
	return
}