func getList(uni *context.Uni, noun string, params ...interface{}) []interface{} { values := convert.ListToMap(params...) desc, err := glue.Identify("/"+noun, uni.Opt["nouns"].(map[string]interface{}), values) inp, data, err := desc.CreateInputs(uni.FilterCreator) if err != nil { panic(err) } if data != nil { inp = append(inp, data) } module := uni.NewModule(desc.VerbLocation) if !module.Exists() { panic("Module does not exist.") } ins := module.Instance() ret := []interface{}{} ret_rec := func(i ...interface{}) { ret = i } ins.Method("Get").Call(ret_rec, inp...) return ret }
// Mainly designed to work from Get or GetSingle func getSub(uni *context.Uni, noun string, params ...interface{}) []interface{} { if uni.Route == nil && uni.Sentence == nil { panic("Nothing to do here.") } s := uni.Sentence r := uni.Route var path string var urls []map[string]interface{} if s.Verb != "Get" && s.Verb != "GetSingle" { path = "/" + strings.Join(r.Words, "/") + "/" + noun urls = append(urls, r.Queries...) urls = append(urls, convert.ListToMap(params...)) } else { path = "/" + strings.Join(r.Words, "/") + "/" + noun urls = append(urls, r.Queries[:len(r.Queries)-1]...) urls = append(urls, convert.ListToMap(params...)) } desc, err := glue.Identify(path, uni.Opt["nouns"].(map[string]interface{}), lang.EncodeQueries(urls, false)) inp, data, err := desc.CreateInputs(uni.FilterCreator) if err != nil { panic(err) } if data != nil { inp = append(inp, data) } module := uni.NewModule(desc.VerbLocation) if !module.Exists() { panic("Module does not exist.") } ins := module.Instance() ret := []interface{}{} ret_rec := func(i ...interface{}) { ret = i } ins.Method(uni.Sentence.Verb).Call(ret_rec, inp...) return ret }