deprecated-oc-catalog/controllers/search.go

32 lines
741 B
Go
Raw Normal View History

2023-03-03 14:43:11 +01:00
package controllers
import (
2024-07-29 18:02:29 +02:00
"cloud.o-forge.io/core/deprecated-oc-catalog/models"
2023-03-03 14:43:11 +01:00
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()
}