package controllers import ( "cloud.o-forge.io/core/deprecated-oc-catalog/models" beego "github.com/beego/beego/v2/server/web" ) type SearchController struct { beego.Controller } // TODO: Search by word is very very inneficent for not small databases // @Title Search by word // @Description find resources by word // @Param word query string true "Word to search across all resources" // @Success 200 {object} models.SearchResult // @Failure 503 Internal error // @router /byWord [get] func (o *SearchController) FindByWord(word string) { if word != "" { ob, err := models.FindByWord(word) if err != nil { o.Data["json"] = err.Error() o.Ctx.Output.Status = 503 } else { o.Data["json"] = ob } } o.ServeJSON() }