modernize ocshared
This commit is contained in:
@@ -45,7 +45,7 @@ func (o *CollaborativeAreaController) Search() {
|
|||||||
// store and return Id or post with UUID
|
// store and return Id or post with UUID
|
||||||
search := o.Ctx.Input.Param(":search")
|
search := o.Ctx.Input.Param(":search")
|
||||||
isDraft := o.Ctx.Input.Query("is_draft")
|
isDraft := o.Ctx.Input.Query("is_draft")
|
||||||
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, nil).Search(nil, search, isDraft == "true")
|
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, nil).Search(nil, search, isDraft == "true", 0, 10000)
|
||||||
o.ServeJSON()
|
o.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ func (o *CollaborativeAreaController) Post() {
|
|||||||
func (o *CollaborativeAreaController) GetAll() {
|
func (o *CollaborativeAreaController) GetAll() {
|
||||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||||
isDraft := o.Ctx.Input.Query("is_draft")
|
isDraft := o.Ctx.Input.Query("is_draft")
|
||||||
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, nil).LoadAll(isDraft == "true")
|
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, nil).LoadAll(isDraft == "true", 0, 10000)
|
||||||
o.ServeJSON()
|
o.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -23,7 +23,7 @@ func (o *RuleController) Search() {
|
|||||||
// store and return Id or post with UUID
|
// store and return Id or post with UUID
|
||||||
search := o.Ctx.Input.Param(":search")
|
search := o.Ctx.Input.Param(":search")
|
||||||
isDraft := o.Ctx.Input.Query("is_draft")
|
isDraft := o.Ctx.Input.Query("is_draft")
|
||||||
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.RULE), user, peerID, groups, nil).Search(nil, search, isDraft == "true")
|
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.RULE), user, peerID, groups, nil).Search(nil, search, isDraft == "true", 0, 10000)
|
||||||
o.ServeJSON()
|
o.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ func (o *RuleController) Post() {
|
|||||||
func (o *RuleController) GetAll() {
|
func (o *RuleController) GetAll() {
|
||||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||||
isDraft := o.Ctx.Input.Query("is_draft")
|
isDraft := o.Ctx.Input.Query("is_draft")
|
||||||
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.RULE), user, peerID, groups, nil).LoadAll(isDraft == "true")
|
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.RULE), user, peerID, groups, nil).LoadAll(isDraft == "true", 0, 10000)
|
||||||
o.ServeJSON()
|
o.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,39 +5,12 @@ import (
|
|||||||
|
|
||||||
oclib "cloud.o-forge.io/core/oc-lib"
|
oclib "cloud.o-forge.io/core/oc-lib"
|
||||||
beego "github.com/beego/beego/v2/server/web"
|
beego "github.com/beego/beego/v2/server/web"
|
||||||
"github.com/beego/beego/v2/server/web/filter/cors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const appname = "oc-shared"
|
const appname = "oc-shared"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Init the oc-lib
|
// Init the oc-lib
|
||||||
// Init the oc-lib
|
oclib.InitAPI(appname)
|
||||||
oclib.Init(appname)
|
|
||||||
|
|
||||||
// Load the right config file
|
|
||||||
o := oclib.GetConfLoader()
|
|
||||||
|
|
||||||
// feed the library with the loaded config
|
|
||||||
oclib.SetConfig(
|
|
||||||
o.GetStringDefault("MONGO_URL", "mongodb://127.0.0.1:27017"),
|
|
||||||
o.GetStringDefault("MONGO_DATABASE", "DC_myDC"),
|
|
||||||
o.GetStringDefault("NATS_URL", "nats://localhost:4222"),
|
|
||||||
o.GetStringDefault("LOKI_URL", ""),
|
|
||||||
o.GetStringDefault("LOG_LEVEL", "info"),
|
|
||||||
)
|
|
||||||
// Beego init
|
|
||||||
beego.BConfig.AppName = appname
|
|
||||||
beego.BConfig.Listen.HTTPPort = o.GetIntDefault("port", 8080)
|
|
||||||
beego.BConfig.WebConfig.DirectoryIndex = true
|
|
||||||
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
|
|
||||||
beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
|
|
||||||
AllowAllOrigins: true,
|
|
||||||
AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
|
|
||||||
AllowHeaders: []string{"Origin", "Authorization", "Content-Type"},
|
|
||||||
ExposeHeaders: []string{"Content-Length", "Content-Type"},
|
|
||||||
AllowCredentials: true,
|
|
||||||
}))
|
|
||||||
|
|
||||||
beego.Run()
|
beego.Run()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user