func (a *ApplicationController) SearchApps(r *knot.WebContext) interface{} { r.Config.OutputType = knot.OutputJson text := "Mandiri" var query *dbox.Filter if text != "" { // query = dbox.Or(dbox.Eq("AppsName", text), dbox.Eq("ID", text)) query = dbox.Eq("AppsName", text) } cursor, err := colonycore.Find(new(colonycore.Application), query) if err != nil { return helper.CreateResult(false, nil, err.Error()) } data := []colonycore.Application{} err = cursor.Fetch(&data, 0, false) fmt.Println("data pencarian : ", data) if err != nil { return helper.CreateResult(false, nil, err.Error()) } defer cursor.Close() return helper.CreateResult(true, data, "") }
func (w *WebGrabberController) SaveScrapperData(r *knot.WebContext) interface{} { r.Config.OutputType = knot.OutputJson payload := new(colonycore.WebGrabber) err := r.GetPayload(payload) fmt.Printf("\n=============\n") fmt.Printf("%#v", payload) fmt.Printf("\n=============\n") if err != nil { return helper.CreateResult(false, nil, err.Error()) } err = colonycore.Delete(payload) if err != nil { return helper.CreateResult(false, nil, err.Error()) } err = colonycore.Save(payload) if err != nil { return helper.CreateResult(false, nil, err.Error()) } fmt.Printf("\n=============\n") fmt.Printf("%#v", payload) fmt.Printf("\n=============\n") return helper.CreateResult(true, payload, "") }
func (d *DataSourceController) RemoveConnection(r *knot.WebContext) interface{} { r.Config.OutputType = knot.OutputJson payload := map[string]interface{}{} err := r.GetPayload(&payload) if err != nil { return helper.CreateResult(false, nil, err.Error()) } id := payload["_id"].(string) ds := new(colonycore.DataSource) cursor, err := colonycore.Find(ds, dbox.Eq("ConnectionID", id)) if err != nil { return helper.CreateResult(false, nil, err.Error()) } defer cursor.Close() if cursor.Count() > 0 { return helper.CreateResult(false, nil, "Cannot delete connection because used on data source") } o := new(colonycore.Connection) o.ID = id err = colonycore.Delete(o) if err != nil { return helper.CreateResult(false, nil, err.Error()) } return helper.CreateResult(true, nil, "") }
func (wc *WidgetChartController) RemoveChart(r *knot.WebContext) interface{} { r.Config.OutputType = knot.OutputJson payload := map[string]interface{}{} if err := r.GetPayload(&payload); !helper.HandleError(err) { return helper.CreateResult(false, nil, err.Error()) } idArray := payload["_id"].([]interface{}) for _, id := range idArray { mapchart := new(colonycore.MapChart) mapchart.ID = id.(string) if err := mapchart.Delete(); !helper.HandleError(err) { return helper.CreateResult(false, nil, err.Error()) } filechart := new(colonycore.Chart) filechart.ID = id.(string) if err := filechart.Remove(); !helper.HandleError(err) { return helper.CreateResult(false, nil, err.Error()) } } return helper.CreateResult(true, payload["_id"], "") }
func (w *WebGrabberController) GetFetchedData(r *knot.WebContext) interface{} { r.Config.OutputType = knot.OutputJson w.PrepareHistoryPath() payload := struct { Driver string Host string Database string Collection string Username string Password string }{} err := r.GetPayload(&payload) if err != nil { return helper.CreateResult(false, nil, err.Error()) } var data []toolkit.M if payload.Driver == "csv" { config := toolkit.M{"useheader": true, "delimiter": ","} query := helper.Query("csv", payload.Host, "", "", "", config) data, err = query.SelectAll("") } else { query := helper.Query("mongo", payload.Host, payload.Database, payload.Username, payload.Password) data, err = query.SelectAll(payload.Collection) } if err != nil { return helper.CreateResult(false, nil, err.Error()) } return helper.CreateResult(true, data, "") }
func (d *DataSourceController) FetchDataSourceMetaData(r *knot.WebContext) interface{} { r.Config.OutputType = knot.OutputJson payload := map[string]interface{}{} err := r.GetPayload(&payload) if err != nil { return helper.CreateResult(false, nil, err.Error()) } connectionID := payload["connectionID"].(string) from := payload["from"].(string) if connectionID == "" { return helper.CreateResult(true, []toolkit.M{}, "") } dataConn := new(colonycore.Connection) err = colonycore.Get(dataConn, connectionID) if err != nil { return helper.CreateResult(false, nil, err.Error()) } res, data, err := d.DoFetchDataSourceMetaData(dataConn, from) if err != nil { return helper.CreateResult(false, nil, err.Error()) } return helper.CreateResult(res, data, "") }
func (s *FileBrowserController) NewFile(r *knot.WebContext) interface{} { r.Config.OutputType = knot.OutputJson server, payload, err := getServer(r, "PAYLOAD") fmt.Println("aaaaa") if err != nil { return helper.CreateResult(false, nil, err.Error()) } if server.RecordID() != nil { if payload.Path != "" { if server.ServerType == SERVER_NODE { setting, err := sshConnect(&server) if err != nil { return helper.CreateResult(false, nil, err.Error()) } err = sshclient.MakeFile(setting, " ", payload.Path, "", false) if err != nil { return helper.CreateResult(false, nil, err.Error()) } return helper.CreateResult(true, nil, "") } else if server.ServerType == SERVER_HDFS { h := setHDFSConnection(server.Host, server.SSHUser) //create file on local tempPath := strings.Replace(GetHomeDir()+"/", "//", "/", -1) if tempPath == "" { return helper.CreateResult(false, nil, "No Temporary Directory") } FileName := strings.Split(payload.Path, "/")[len(strings.Split(payload.Path, "/"))-1] file, err := os.Create(tempPath + FileName) if err != nil { return helper.CreateResult(false, nil, err.Error()) } defer file.Close() //put new file to hdfs err = h.Put(tempPath+FileName, strings.Replace(payload.Path+"/", "//", "/", -1), "", nil, &server) if err != nil { return helper.CreateResult(false, nil, err.Error()) } //remove file on local // err = os.Remove(tempPath + FileName) // if err != nil { // return helper.CreateResult(false, nil, err.Error()) // } return helper.CreateResult(true, "", "") } } return helper.CreateResult(false, nil, "Please check your param") } return helper.CreateResult(false, nil, "") }
func (d *DataGrabberController) SaveDataGrabber(r *knot.WebContext) interface{} { r.Config.OutputType = knot.OutputJson payload := new(colonycore.DataGrabber) err := r.GetPayload(payload) if err != nil { return helper.CreateResult(false, nil, err.Error()) } before := new(colonycore.DataGrabber) err = colonycore.Get(before, payload.ID) if err != nil { return helper.CreateResult(false, nil, err.Error()) } err = colonycore.Delete(payload) if err != nil { return helper.CreateResult(false, nil, err.Error()) } payload.RunAt = before.RunAt err = colonycore.Save(payload) if err != nil { return helper.CreateResult(false, nil, err.Error()) } return helper.CreateResult(true, payload, "") }
func (w *WebGrabberController) RemoveMultipleWebGrabber(r *knot.WebContext) interface{} { r.Config.OutputType = knot.OutputJson payload := map[string]interface{}{} err := r.GetPayload(&payload) if err != nil { return helper.CreateResult(false, nil, err.Error()) } idArray := payload["_id"].([]interface{}) for _, id := range idArray { o := new(colonycore.WebGrabber) o.ID = id.(string) err = colonycore.Delete(o) if err != nil { return helper.CreateResult(false, nil, err.Error()) } } if err := w.SyncConfig(); err != nil { return helper.CreateResult(false, nil, err.Error()) } return helper.CreateResult(true, nil, "") }
func (a *GroupController) FindUserLdap(r *knot.WebContext) interface{} { r.Config.OutputType = knot.OutputJson payload := map[string]interface{}{} err := r.GetPayload(&payload) if err != nil { return helper.CreateResult(false, nil, err.Error()) } addr := payload["Address"].(string) basedn := payload["BaseDN"].(string) filter := payload["Filter"].(string) username := payload["Username"].(string) password := payload["Password"].(string) var attr []string err = toolkit.Serde(payload["Attribute"], &attr, "json") if err != nil { return helper.CreateResult(false, err, "error") } param := toolkit.M{} param.Set("username", username) param.Set("password", password) param.Set("attributes", attr) arrm, err := acl.FindDataLdap(addr, basedn, filter, param) if err != nil { return helper.CreateResult(false, err, "error") } return helper.CreateResult(true, arrm, "success") }
func (d *DataGrabberController) FindDataGrabber(r *knot.WebContext) interface{} { r.Config.OutputType = knot.OutputJson //~ payload := map[string]string{"inputText":"test"} payload := map[string]interface{}{} err := r.GetPayload(&payload) if err != nil { return helper.CreateResult(false, nil, err.Error()) } text := payload["inputText"].(string) textLow := strings.ToLower(text) var query *dbox.Filter valueInt, errv := strconv.Atoi(text) fmt.Printf("", valueInt) fmt.Printf("", errv) if errv == nil { // == try useing Eq for support integer query = dbox.Or(dbox.Eq("GrabInterval", valueInt), dbox.Eq("TimeoutInterval", valueInt)) } else { // == try useing Contains for support autocomplite query = dbox.Or(dbox.Contains("_id", text), dbox.Contains("_id", textLow), dbox.Contains("DataSourceOrigin", text), dbox.Contains("DataSourceOrigin", textLow), dbox.Contains("DataSourceDestination", text), dbox.Contains("DataSourceDestination", textLow), dbox.Contains("IntervalType", text), dbox.Contains("IntervalType", textLow)) } data := []colonycore.DataGrabber{} cursor, err := colonycore.Find(new(colonycore.DataGrabber), query) cursor.Fetch(&data, 0, false) if err != nil { return helper.CreateResult(false, nil, err.Error()) } defer cursor.Close() return helper.CreateResult(true, data, "") }
func (a *GroupController) SaveGroupConfigLdap(r *knot.WebContext) interface{} { r.Config.OutputType = knot.OutputJson payload := map[string]interface{}{} err := r.GetPayload(&payload) if err != nil { return helper.CreateResult(false, nil, err.Error()) } o := new(colonycore.Ldap) o.ID = payload["Address"].(string) o.Address = payload["Address"].(string) o.BaseDN = payload["BaseDN"].(string) o.FilterGroup = payload["Filter"].(string) o.Username = payload["Username"].(string) //o.Password = payload["Password"].(string) err = toolkit.Serde(payload["Attribute"], &o.AttributesGroup, "json") if err != nil { return helper.CreateResult(false, err.Error(), "error") } err = colonycore.Save(o) if err != nil { return helper.CreateResult(false, o, err.Error()) } return helper.CreateResult(true, o, "") }
func (a *GroupController) GetLdapdataAddress(r *knot.WebContext) interface{} { r.Config.OutputType = knot.OutputJson autoFilters := []*dbox.Filter{} var query *dbox.Filter if len(autoFilters) > 0 { query = dbox.And(autoFilters...) } cursor, err := colonycore.Find(new(colonycore.Ldap), query) if err != nil { return helper.CreateResult(false, nil, err.Error()) } data := []colonycore.Ldap{} err = cursor.Fetch(&data, 0, false) if err != nil { return helper.CreateResult(false, nil, err.Error()) } defer cursor.Close() return helper.CreateResult(true, data, "") }
func (s *ServerController) SaveServers(r *knot.WebContext) interface{} { // r.Config.OutputType = knot.OutputJson // payload := map[string]interface{}{} // err := r.GetPayload(&payload) // if err != nil { // return helper.CreateResult(false, nil, err.Error()) // } data := new(colonycore.Server) data.ID = "192.168.0.200" data.Type = "local" data.Folder = "/data" data.OS = "linux" data.Enable = true data.SSHType = "DDL: Credential" data.SSHFile = "knot-server" data.SSHUser = "******" data.SSHPass = "******" err := colonycore.Delete(data) if err != nil { return helper.CreateResult(false, nil, err.Error()) } err = colonycore.Save(data) if err != nil { return helper.CreateResult(false, nil, err.Error()) } // Printf("data:%v\n", data) return helper.CreateResult(true, nil, "") }
func (l *LoginController) SavePassword(r *knot.WebContext) interface{} { r.Config.OutputType = knot.OutputJson payload := toolkit.M{} err := r.GetPayload(&payload) if err != nil { return helper.CreateResult(false, nil, err.Error()) } if !payload.Has("newpassword") || !payload.Has("userid") { return helper.CreateResult(false, nil, "Data is not complete") } switch { case payload.Has("tokenid"): err = acl.ChangePasswordToken(toolkit.ToString(payload["userid"]), toolkit.ToString(payload["newpassword"]), toolkit.ToString(payload["tokenid"])) default: // check sessionid first savedsessionid := "" //change with get session //======================= userid, err := acl.FindUserBySessionID(savedsessionid) if err == nil && userid == toolkit.ToString(payload["userid"]) { err = acl.ChangePassword(toolkit.ToString(payload["userid"]), toolkit.ToString(payload["newpassword"])) } else if err == nil { err = errors.New("Userid is not match") } } return helper.CreateResult(true, nil, "save password success") }
func (a *ApplicationController) CreateNewFile(r *knot.WebContext) interface{} { r.Config.OutputType = knot.OutputJson payload := map[string]interface{}{} err := r.GetPayload(&payload) if err != nil { return helper.CreateResult(false, nil, err.Error()) } Type := payload["Type"].(string) Filename := payload["Filename"].(string) pathfolder := payload["Path"].(string) ID := payload["ID"].(string) if Type == "folder" { os.MkdirAll(filepath.Join(unzipDest, ID, pathfolder, Filename), 0755) } else { content := []byte("") if payload["Content"].(string) != "" { content = []byte(payload["Content"].(string)) } err = ioutil.WriteFile(filepath.Join(unzipDest, ID, pathfolder, Filename), content, 0644) if err != nil { return helper.CreateResult(false, nil, err.Error()) } } return helper.CreateResult(true, err, "") }
func (d *DataSourceController) GetDataSources(r *knot.WebContext) interface{} { r.Config.OutputType = knot.OutputJson payload := map[string]interface{}{} err := r.GetPayload(&payload) if err != nil { return helper.CreateResult(false, nil, err.Error()) } search := payload["search"].(string) var query *dbox.Filter query = dbox.Or(dbox.Contains("_id", search), dbox.Contains("ConnectionID", search)) cursor, err := colonycore.Find(new(colonycore.DataSource), query) if err != nil { return helper.CreateResult(false, nil, err.Error()) } data := []colonycore.DataSource{} err = cursor.Fetch(&data, 0, false) if err != nil { return helper.CreateResult(false, nil, err.Error()) } defer cursor.Close() return helper.CreateResult(true, data, "") }
func (p *PageController) LoadWidgetPageData(r *knot.WebContext) interface{} { r.Config.OutputType = knot.OutputJson payload := []toolkit.M{} if err := r.GetPayload(&payload); err != nil { return helper.CreateResult(false, nil, err.Error()) } result := toolkit.M{} for _, each := range payload { filter := each.GetString("filter") namespace := each.GetString("namespace") fields := strings.Split(each.Get("fields").(string), ",") dsID := each.GetString("value") opt := toolkit.M{"fields": fields, "value": filter} data, err := helper.FetchDataFromDSWithFilter(dsID, 0, opt) if err != nil { return helper.CreateResult(false, nil, err.Error()) } result.Set(namespace, data) } return helper.CreateResult(true, result, "") }
func (a *AdministrationController) SaveAccess(r *knot.WebContext) interface{} { r.Config.OutputType = knot.OutputJson a.InitialSetDatabase() payload := map[string]interface{}{} err := r.GetPayload(&payload) if err != nil { return helper.CreateResult(false, nil, err.Error()) } initAccess := new(acl.Access) initAccess.ID = payload["_id"].(string) initAccess.Title = payload["Title"].(string) initAccess.Group1 = payload["Group1"].(string) initAccess.Group2 = payload["Group2"].(string) initAccess.Group3 = payload["Group3"].(string) initAccess.Enable = payload["Enable"].(bool) initAccess.SpecialAccess1 = payload["SpecialAccess1"].(string) initAccess.SpecialAccess2 = payload["SpecialAccess2"].(string) initAccess.SpecialAccess3 = payload["SpecialAccess3"].(string) initAccess.SpecialAccess4 = payload["SpecialAccess4"].(string) err = acl.Save(initAccess) if err != nil { return helper.CreateResult(true, nil, err.Error()) } return helper.CreateResult(true, initAccess, "sukses") }
func (d *DataGrabberController) GetTransformedData(r *knot.WebContext) interface{} { r.Config.OutputType = knot.OutputJson payload := struct { ID string `json:"_id",bson:"_id"` Date string }{} err := r.GetPayload(&payload) if err != nil { return helper.CreateResult(false, nil, err.Error()) } filepath := filepath.Join(dgOutputPath, fmt.Sprintf("%s.json", payload.Date)) bytes, err := ioutil.ReadFile(filepath) if err != nil { return helper.CreateResult(false, nil, err.Error()) } transformedData := []toolkit.M{} err = json.Unmarshal(bytes, &transformedData) if err != nil { return helper.CreateResult(false, nil, err.Error()) } return helper.CreateResult(true, transformedData, "") }
func (s *ServerController) DeleteServers(r *knot.WebContext) interface{} { r.Config.OutputType = knot.OutputJson payload := new(colonycore.Server) var data []string err := r.GetPayload(&data) if err != nil { return helper.CreateResult(false, nil, err.Error()) } for _, val := range data { if val != "" { payload.ID = val err = colonycore.Delete(payload) if err != nil { return helper.CreateResult(false, nil, err.Error()) } // delPath := filepath.Join(unzipDest, payload.ID) // err = deleteDirectory(unzipDest, delPath, payload.ID) // if err != nil { // fmt.Println("Error : ", err) // return err // } } } return helper.CreateResult(true, data, "") }
func (d *DataGrabberController) StopTransformation(r *knot.WebContext) interface{} { r.Config.OutputType = knot.OutputJson dataGrabber := new(colonycore.DataGrabber) err := r.GetPayload(dataGrabber) if err != nil { return helper.CreateResult(false, nil, err.Error()) } logFileName := dataGrabber.ID logFilePattern := "" logConf, err := toolkit.NewLog(false, true, dgLogPath, logFileName, logFilePattern) if err != nil { logConf.AddLog(err.Error(), "ERROR") } if _, ok := serviceHolder[dataGrabber.ID]; ok { serviceHolder[dataGrabber.ID] = false delete(serviceHolder, dataGrabber.ID) message := fmt.Sprintf("===> Transformation stopped! %s -> %s", dataGrabber.DataSourceOrigin, dataGrabber.DataSourceDestination) logConf.AddLog(message, "SUCCESS") fmt.Println(message) } return helper.CreateResult(true, nil, "") }
func (w *WebGrabberController) StopService(r *knot.WebContext) interface{} { r.Config.OutputType = knot.OutputJson w.PrepareHistoryPath() payload := new(colonycore.WebGrabber) err := r.GetPayload(payload) if err != nil { return helper.CreateResult(false, nil, err.Error()) } err = colonycore.Get(payload, payload.ID) if err != nil { return helper.CreateResult(false, nil, err.Error()) } o, err := toolkit.ToM(payload) if err != nil { return helper.CreateResult(false, nil, err.Error()) } err, isRun := modules.StopProcess([]interface{}{o}) if err != nil { return helper.CreateResult(false, nil, err.Error()) } return helper.CreateResult(isRun, nil, "") }
func (d *DataGrabberController) SaveDataGrabber(r *knot.WebContext) interface{} { r.Config.OutputType = knot.OutputJson payload := new(colonycore.DataGrabber) err := r.GetPayload(payload) if err != nil { return helper.CreateResult(false, nil, err.Error()) } _, err = d.GenerateNewField(payload) if err != nil { return helper.CreateResult(false, nil, err.Error()) } before := new(colonycore.DataGrabber) cursor, err := colonycore.Find(before, dbox.Eq("_id", payload.ID)) if err != nil { return helper.CreateResult(false, nil, err.Error()) } defer cursor.Close() payload.RunAt = before.RunAt err = colonycore.Save(payload) if err != nil { return helper.CreateResult(false, nil, err.Error()) } return helper.CreateResult(true, payload, "") }
func (w *WebGrabberController) GetLog(r *knot.WebContext) interface{} { r.Config.OutputType = knot.OutputJson w.PrepareHistoryPath() payload := struct { ID string `json:"_id"` Date string `json:"date"` }{} err := r.GetPayload(&payload) if err != nil { return helper.CreateResult(false, nil, err.Error()) } wg := new(colonycore.WebGrabber) err = colonycore.Get(wg, payload.ID) if err != nil { return helper.CreateResult(false, nil, err.Error()) } o, err := toolkit.ToM(wg) if err != nil { return helper.CreateResult(false, nil, err.Error()) } history := modules.NewHistory(payload.ID) logs := history.GetLog([]interface{}{o}, payload.Date) return helper.CreateResult(true, logs, "") }
func (ws *WidgetSelectorController) GetSelectorConfigs(r *knot.WebContext) interface{} { r.Config.OutputType = knot.OutputJson payload := map[string]interface{}{} err := r.GetPayload(&payload) if err != nil { return helper.CreateResult(false, nil, err.Error()) } var search string search = payload["search"].(string) var query *dbox.Filter if search != "" { query = dbox.Contains("_id", search) } data := []colonycore.Selector{} cursor, err := colonycore.Find(new(colonycore.Selector), query) if err != nil { return helper.CreateResult(false, nil, err.Error()) } err = cursor.Fetch(&data, 0, false) if err != nil { return helper.CreateResult(false, nil, err.Error()) } defer cursor.Close() return helper.CreateResult(true, data, "") }
func (d *DataSourceController) FindConnection(r *knot.WebContext) interface{} { r.Config.OutputType = knot.OutputJson //~ payload := map[string]string{"inputText":"tes","inputDrop":""} payload := map[string]interface{}{} err := r.GetPayload(&payload) if err != nil { return helper.CreateResult(false, nil, err.Error()) } text := payload["inputText"].(string) pilih := payload["inputDrop"].(string) textLow := strings.ToLower(text) // == try useing Contains for support autocomplite var query *dbox.Filter if text != "" { query = dbox.Or(dbox.Contains("_id", text), dbox.Contains("_id", textLow), dbox.Contains("Database", text), dbox.Contains("Database", textLow), dbox.Contains("Driver", text), dbox.Contains("Driver", textLow), dbox.Contains("Host", text), dbox.Contains("Host", textLow), dbox.Contains("UserName", text), dbox.Contains("UserName", textLow), dbox.Contains("Password", text), dbox.Contains("Password", textLow)) } if pilih != "" { query = dbox.And(query, dbox.Eq("Driver", pilih)) } data := []colonycore.Connection{} cursor, err := colonycore.Find(new(colonycore.Connection), query) cursor.Fetch(&data, 0, false) if err != nil { return helper.CreateResult(false, nil, err.Error()) } defer cursor.Close() return helper.CreateResult(true, data, "") }
func (s *ServerController) PingServer(r *knot.WebContext) interface{} { r.Config.OutputType = knot.OutputJson payload := new(colonycore.ServerByType) err := r.GetPayload(&payload) if err != nil { return helper.CreateResult(false, nil, err.Error()) } err = colonycore.Get(payload, payload.ID) if err != nil { return helper.CreateResult(false, nil, err.Error()) } res := toolkit.M{ "ssh": toolkit.M{"isUP": true, "message": ""}, "hdfs": toolkit.M{"isUP": true, "message": ""}, } if _, err := payload.Ping("ssh"); err != nil { res["ssh"] = toolkit.M{"isUP": false, "message": err.Error()} } if _, err := payload.Ping("hdfs"); err != nil { res["hdfs"] = toolkit.M{"isUP": false, "message": err.Error()} } return helper.CreateResult(true, res, "") }
func (d *DataSourceController) RemoveDataSource(r *knot.WebContext) interface{} { r.Config.OutputType = knot.OutputJson payload := map[string]interface{}{} err := r.GetPayload(&payload) if err != nil { return helper.CreateResult(false, nil, err.Error()) } id := payload["_id"].(string) dg := new(colonycore.DataGrabber) filter := dbox.Or(dbox.Eq("DataSourceOrigin", id), dbox.Eq("DataSourceDestination", id)) cursor, err := colonycore.Find(dg, filter) if err != nil { return helper.CreateResult(false, nil, err.Error()) } defer cursor.Close() if cursor.Count() > 0 { return helper.CreateResult(false, nil, "Cannot delete data source because used on data grabber") } o := new(colonycore.DataSource) o.ID = id err = colonycore.Delete(o) if err != nil { return helper.CreateResult(false, nil, err.Error()) } return helper.CreateResult(true, nil, "") }
func (d *DataBrowserController) GetBrowser(r *knot.WebContext) interface{} { r.Config.OutputType = knot.OutputJson payload := map[string]interface{}{} err := r.GetPayload(&payload) if err != nil { return helper.CreateResult(false, nil, err.Error()) } search := payload["search"].(string) // search = "" var query *dbox.Filter if search != "" { query = dbox.Contains("BrowserName", search) } data := []colonycore.DataBrowser{} cursor, err := colonycore.Find(new(colonycore.DataBrowser), query) if err != nil { return helper.CreateResult(false, nil, err.Error()) } err = cursor.Fetch(&data, 0, false) if err != nil { return helper.CreateResult(false, nil, err.Error()) } defer cursor.Close() return helper.CreateResult(true, data, "") }