generate paths
This commit is contained in:
parent
71d97d7617
commit
d397073d04
@ -4,6 +4,8 @@ import (
|
||||
"encoding/json"
|
||||
|
||||
oclib "cloud.o-forge.io/core/oc-lib"
|
||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||
"cloud.o-forge.io/core/oc-lib/tools"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
@ -32,10 +34,25 @@ func (o *SharedWorkspaceController) Search() {
|
||||
// @router /:id [put]
|
||||
func (o *SharedWorkspaceController) Put() {
|
||||
// store and return Id or post with UUID
|
||||
var paths = map[string]map[tools.METHOD]string{
|
||||
utils.SHARED_WORKSPACE.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
|
||||
},
|
||||
utils.WORKSPACE.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/",
|
||||
},
|
||||
utils.WORKFLOW.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/",
|
||||
},
|
||||
}
|
||||
var res map[string]interface{}
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, id)
|
||||
caller := tools.NewHTTPCaller(paths)
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, id, caller)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@ -45,9 +62,24 @@ func (o *SharedWorkspaceController) Put() {
|
||||
// @Success 200 {shared workspace} models.shared_workspace
|
||||
// @router / [post]
|
||||
func (o *SharedWorkspaceController) Post() {
|
||||
var paths = map[string]map[tools.METHOD]string{
|
||||
utils.SHARED_WORKSPACE.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
|
||||
},
|
||||
utils.WORKSPACE.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/",
|
||||
},
|
||||
utils.WORKFLOW.String(): {
|
||||
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/:id",
|
||||
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/",
|
||||
},
|
||||
}
|
||||
var res map[string]interface{}
|
||||
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
||||
o.Data["json"] = oclib.StoreOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res)
|
||||
caller := tools.NewHTTPCaller(paths)
|
||||
o.Data["json"] = oclib.StoreOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, caller)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
|
3
main.go
3
main.go
@ -40,6 +40,9 @@ func main() {
|
||||
o.GetStringDefault("MONGO_DATABASE", "DC_myDC"),
|
||||
)
|
||||
oclib.Init("oc-shared")
|
||||
oclib.AddPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), o.GetStringDefault("SHARED_WORKSPACE_URL", ":8091"))
|
||||
oclib.AddPath(oclib.LibDataEnum(oclib.WORKSPACE), o.GetStringDefault("WORKSPACE_URL", ":8089"))
|
||||
oclib.AddPath(oclib.LibDataEnum(oclib.WORKFLOW), o.GetStringDefault("WORKFLOW_URL", ":8088"))
|
||||
// Normal beego init
|
||||
//if beego.BConfig.RunMode == "dev" {
|
||||
beego.BConfig.WebConfig.DirectoryIndex = true
|
||||
|
Loading…
Reference in New Issue
Block a user