deprecated-oc-search/controllers/default.go
2024-02-15 10:48:40 +01:00

42 lines
1.3 KiB
Go

package controllers
import (
OCCatalog_cli "oc-search/api-client/oc-catalog"
"github.com/beego/beego/logs"
beego "github.com/beego/beego/v2/server/web"
)
// MainController is in charge of the main page
type MainController struct {
beego.Controller
}
var OCCatalogAPI *OCCatalog_cli.APIClient
func init() {
// OcCatalogURL := conf.GetConfig().OcCatalogUrl
// if OcCatalogURL == "" {
// panic("OcCatalogUrl is blank")
// }
// auth := context.WithValue(context.Background(), OCCatalog_cli.ContextAPIKey, OCCatalog_cli.APIKey{Key: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdXRob3JpemVkIjp0cnVlLCJleHAiOjE2MTI1OTI3MDIsInVzZXJfaWQiOiJ4ZCJ9.kTLb1FtpdnaobUpe5u9Jw8S7Cc6gf7ExmU4U3XMcC2o"})
OCCatalogAPI = OCCatalog_cli.NewAPIClient(&OCCatalog_cli.Configuration{BasePath: "http://"+ "oc-catalog:8080" +"/v1",
DefaultHeader: map[string]string{
"authorization": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdXRob3JpemVkIjp0cnVlLCJleHAiOjE2MTMwMDI0NjAsInVzZXJfaWQiOiJhc2QifQ.TXT18aeulnCrtedKKFVaD0BapOTdVAFcJJdVS7zk0I8",
},
})
//TODO: Test API is reachable or throw exception
}
// Get provides the main page
func (c *MainController) Get() {
logs.Debug("received : %v",c.Ctx.Input.RequestBody)
c.Data["Website"] = "beego.me"
c.Data["Email"] = "astaxie@gmail.com"
c.TplName = "index.tpl"
}