Compare commits
10 Commits
f56a5d0dd3
...
demo-alpr
| Author | SHA1 | Date | |
|---|---|---|---|
| e3a3e7ed4a | |||
| e45f7c2bf8 | |||
| d76473bb0f | |||
| edc8915e2f | |||
| 7452451f28 | |||
| 75b90ac64c | |||
| 47eb681f3b | |||
| b0de32c0d3 | |||
| ed9e98e5f9 | |||
| 7d391e4059 |
10
Makefile
10
Makefile
@@ -6,6 +6,14 @@ build: clean
|
||||
run:
|
||||
bee run -gendoc=true -downdoc=true
|
||||
|
||||
purge:
|
||||
lsof -t -i:8091 | xargs kill | true
|
||||
|
||||
run-dev:
|
||||
bee generate routers && bee run -gendoc=true -downdoc=true -runmode=prod
|
||||
|
||||
dev: purge run-dev
|
||||
|
||||
debug:
|
||||
bee run -downdebug -gendebug
|
||||
|
||||
@@ -24,4 +32,4 @@ publish-registry:
|
||||
|
||||
all: docker publish-kind publish-registry
|
||||
|
||||
.PHONY: build run clean docker publish-kind publish-registry
|
||||
.PHONY: build run clean docker publish-kind publish-registry
|
||||
|
||||
@@ -6,6 +6,8 @@ To build :
|
||||
|
||||
bee generate routers
|
||||
bee run -gendoc=true -downdoc=true
|
||||
OR
|
||||
make dev
|
||||
|
||||
If default Swagger page is displayed instead of tyour api, change url in swagger/index.html file to :
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"slices"
|
||||
|
||||
oclib "cloud.o-forge.io/core/oc-lib"
|
||||
"cloud.o-forge.io/core/oc-lib/config"
|
||||
"cloud.o-forge.io/core/oc-lib/tools"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
@@ -36,12 +37,15 @@ var paths = map[tools.DataType]map[tools.METHOD]string{ // paths used to call ot
|
||||
// @Title Search
|
||||
// @Description search shared workspace
|
||||
// @Param search path string true "the word search you want to get"
|
||||
// @Param is_draft query string false "draft wished"
|
||||
// @Success 200 {shared workspace} models.shared_workspace
|
||||
// @router /search/:search [get]
|
||||
func (o *CollaborativeAreaController) Search() {
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
// store and return Id or post with UUID
|
||||
search := o.Ctx.Input.Param(":search")
|
||||
o.Data["json"] = oclib.Search(nil, search, oclib.LibDataEnum(tools.COLLABORATIVE_AREA))
|
||||
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.ServeJSON()
|
||||
}
|
||||
|
||||
@@ -52,6 +56,7 @@ func (o *CollaborativeAreaController) Search() {
|
||||
// @Success 200 {shared workspace} models.shared_workspace
|
||||
// @router /:id [put]
|
||||
func (o *CollaborativeAreaController) Put() {
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
// store and return Id or post with UUID
|
||||
var res map[string]interface{}
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
@@ -59,7 +64,7 @@ func (o *CollaborativeAreaController) Put() {
|
||||
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
|
||||
caller.Disabled = oclib.IsQueryParamsEquals(o.Ctx.Input, "is_remote", true)
|
||||
fmt.Println("UPDATE", res)
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), res, id, caller)
|
||||
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, caller).UpdateOne(res, id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@@ -69,20 +74,24 @@ func (o *CollaborativeAreaController) Put() {
|
||||
// @Success 200 {shared workspace} models.shared_workspace
|
||||
// @router / [post]
|
||||
func (o *CollaborativeAreaController) Post() {
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
|
||||
caller.Disabled = oclib.IsQueryParamsEquals(o.Ctx.Input, "is_remote", true)
|
||||
var res map[string]interface{}
|
||||
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
||||
o.Data["json"] = oclib.StoreOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), res, caller)
|
||||
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, caller).StoreOne(res)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title GetAll
|
||||
// @Description find shared workspace by id
|
||||
// @Param is_draft query string false "draft wished"
|
||||
// @Success 200 {shared_workspace} models.shared_workspace
|
||||
// @router / [get]
|
||||
func (o *CollaborativeAreaController) GetAll() {
|
||||
o.Data["json"] = oclib.LoadAll(oclib.LibDataEnum(tools.COLLABORATIVE_AREA))
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
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.ServeJSON()
|
||||
}
|
||||
|
||||
@@ -92,8 +101,9 @@ func (o *CollaborativeAreaController) GetAll() {
|
||||
// @Success 200 {shared workspace} models.shared_workspace
|
||||
// @router /:id [get]
|
||||
func (o *CollaborativeAreaController) Get() {
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
o.Data["json"] = oclib.LoadOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), id)
|
||||
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, nil).LoadOne(id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@@ -104,11 +114,12 @@ func (o *CollaborativeAreaController) Get() {
|
||||
// @Success 200 {shared workspace} models.shared_workspace
|
||||
// @router /:id/workspace/:id2 [delete]
|
||||
func (o *CollaborativeAreaController) RemoveWorkspace() {
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
|
||||
caller.Disabled = oclib.IsQueryParamsEquals(o.Ctx.Input, "is_remote", true)
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
id2 := o.Ctx.Input.Param(":id2")
|
||||
r := oclib.LoadOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), id)
|
||||
r := oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, nil).LoadOne(id)
|
||||
shared := r.ToCollaborativeArea()
|
||||
newWorkspace := []string{}
|
||||
if slices.Contains(shared.Workspaces, id2) {
|
||||
@@ -119,7 +130,8 @@ func (o *CollaborativeAreaController) RemoveWorkspace() {
|
||||
}
|
||||
shared.Workspaces = newWorkspace
|
||||
}
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), shared.Serialize(), id, caller)
|
||||
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, caller).UpdateOne(
|
||||
shared.Serialize(shared), id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@@ -130,11 +142,12 @@ func (o *CollaborativeAreaController) RemoveWorkspace() {
|
||||
// @Success 200 {shared workspace} models.shared_workspace
|
||||
// @router /:id/workflow/:id2 [delete]
|
||||
func (o *CollaborativeAreaController) RemoveWorkflow() {
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
|
||||
caller.Disabled = oclib.IsQueryParamsEquals(o.Ctx.Input, "is_remote", true)
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
id2 := o.Ctx.Input.Param(":id2")
|
||||
r := oclib.LoadOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), id)
|
||||
r := oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, nil).LoadOne(id)
|
||||
shared := r.ToCollaborativeArea()
|
||||
newWorkflows := []string{}
|
||||
for _, w := range shared.Workflows {
|
||||
@@ -143,7 +156,8 @@ func (o *CollaborativeAreaController) RemoveWorkflow() {
|
||||
}
|
||||
}
|
||||
shared.Workflows = newWorkflows
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), shared.Serialize(), id, caller)
|
||||
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, caller).UpdateOne(
|
||||
shared.Serialize(shared), id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@@ -154,14 +168,15 @@ func (o *CollaborativeAreaController) RemoveWorkflow() {
|
||||
// @Success 200 {shared workspace} models.shared_workspace
|
||||
// @router /:id/peer/:id2 [delete]
|
||||
func (o *CollaborativeAreaController) RemovePeer() {
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
|
||||
caller.Disabled = oclib.IsQueryParamsEquals(o.Ctx.Input, "is_remote", true)
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
id2 := o.Ctx.Input.Param(":id2")
|
||||
r := oclib.LoadOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), id)
|
||||
r := oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, nil).LoadOne(id)
|
||||
shared := r.ToCollaborativeArea()
|
||||
newPeers := []string{}
|
||||
if shared.CreatorID != id2 {
|
||||
newPeers := map[string][]string{}
|
||||
if shared.CreatorID == id2 {
|
||||
o.Data["json"] = map[string]interface{}{
|
||||
"data": nil,
|
||||
"code": 409,
|
||||
@@ -170,15 +185,28 @@ func (o *CollaborativeAreaController) RemovePeer() {
|
||||
o.ServeJSON()
|
||||
return
|
||||
}
|
||||
if slices.Contains(shared.Peers, id) && shared.CreatorID != id2 {
|
||||
for _, peer := range shared.Peers {
|
||||
if peer != id2 {
|
||||
newPeers = append(newPeers, peer)
|
||||
}
|
||||
if shared.AllowedPeersGroup != nil {
|
||||
keys := make([]string, len(shared.AllowedPeersGroup))
|
||||
i := 0
|
||||
for k := range shared.AllowedPeersGroup {
|
||||
keys[i] = k
|
||||
i++
|
||||
}
|
||||
if slices.Contains(keys, id) && shared.CreatorID != id2 {
|
||||
for _, peer := range keys {
|
||||
if peer != id2 {
|
||||
if config.GetConfig().Whitelist {
|
||||
newPeers[peer] = []string{"*"}
|
||||
} else {
|
||||
newPeers[peer] = []string{}
|
||||
}
|
||||
}
|
||||
}
|
||||
shared.AllowedPeersGroup = newPeers
|
||||
}
|
||||
shared.Peers = newPeers
|
||||
}
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), shared.Serialize(), id, caller)
|
||||
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, caller).UpdateOne(
|
||||
shared.Serialize(shared), id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@@ -189,11 +217,12 @@ func (o *CollaborativeAreaController) RemovePeer() {
|
||||
// @Success 200 {shared workspace} models.shared_workspace
|
||||
// @router /:id/rule/:id2 [delete]
|
||||
func (o *CollaborativeAreaController) RemoveRule() {
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
|
||||
caller.Disabled = oclib.IsQueryParamsEquals(o.Ctx.Input, "is_remote", true)
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
id2 := o.Ctx.Input.Param(":id2")
|
||||
r := oclib.LoadOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), id)
|
||||
r := oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, nil).LoadOne(id)
|
||||
shared := r.ToCollaborativeArea()
|
||||
newRules := []string{}
|
||||
if shared != nil && slices.Contains(shared.Rules, id2) {
|
||||
@@ -204,7 +233,8 @@ func (o *CollaborativeAreaController) RemoveRule() {
|
||||
}
|
||||
shared.Rules = newRules
|
||||
}
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), shared.Serialize(), id, caller)
|
||||
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, caller).UpdateOne(
|
||||
shared.Serialize(shared), id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@@ -215,11 +245,12 @@ func (o *CollaborativeAreaController) RemoveRule() {
|
||||
// @Success 200 {shared workspace} models.shared_workspace
|
||||
// @router /:id/workspace/:id2 [post]
|
||||
func (o *CollaborativeAreaController) AddWorkspace() {
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
|
||||
caller.Disabled = oclib.IsQueryParamsEquals(o.Ctx.Input, "is_remote", true)
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
id2 := o.Ctx.Input.Param(":id2")
|
||||
r := oclib.LoadOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), id)
|
||||
r := oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, nil).LoadOne(id)
|
||||
if r.Code != 200 {
|
||||
o.Data["json"] = r
|
||||
o.ServeJSON()
|
||||
@@ -229,7 +260,8 @@ func (o *CollaborativeAreaController) AddWorkspace() {
|
||||
if shared != nil && !slices.Contains(shared.Workspaces, id2) {
|
||||
shared.Workspaces = append(shared.Workspaces, id2)
|
||||
}
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), shared.Serialize(), id, caller)
|
||||
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, caller).UpdateOne(
|
||||
shared.Serialize(shared), id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@@ -240,16 +272,23 @@ func (o *CollaborativeAreaController) AddWorkspace() {
|
||||
// @Success 200 {shared workspace} models.shared_workspace
|
||||
// @router /:id/workflow/:id2 [post]
|
||||
func (o *CollaborativeAreaController) AddWorkflow() {
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
|
||||
caller.Disabled = oclib.IsQueryParamsEquals(o.Ctx.Input, "is_remote", true)
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
id2 := o.Ctx.Input.Param(":id2")
|
||||
r := oclib.LoadOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), id)
|
||||
r := oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, nil).LoadOne(id)
|
||||
if r.Code != 200 {
|
||||
o.Data["json"] = r
|
||||
o.ServeJSON()
|
||||
return
|
||||
}
|
||||
shared := r.ToCollaborativeArea()
|
||||
if shared != nil && !slices.Contains(shared.Workflows, id2) {
|
||||
shared.Workflows = append(shared.Workflows, id2)
|
||||
}
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), shared.Serialize(), id, caller)
|
||||
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, caller).UpdateOne(
|
||||
shared.Serialize(shared), id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@@ -257,19 +296,29 @@ func (o *CollaborativeAreaController) AddWorkflow() {
|
||||
// @Description find shared workspace by id
|
||||
// @Param id path string true "the id you want to get"
|
||||
// @Param id2 path string true "the id you want to add"
|
||||
// @Param body body models.workspace true "The shared workspace content"
|
||||
// @Success 200 {shared workspace} models.shared_workspace
|
||||
// @router /:id/peer/:id2 [post]
|
||||
func (o *CollaborativeAreaController) AddPeer() {
|
||||
var res []string
|
||||
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
|
||||
caller.Disabled = oclib.IsQueryParamsEquals(o.Ctx.Input, "is_remote", true)
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
id2 := o.Ctx.Input.Param(":id2")
|
||||
r := oclib.LoadOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), id)
|
||||
r := oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, nil).LoadOne(id)
|
||||
shared := r.ToCollaborativeArea()
|
||||
if shared != nil && !slices.Contains(shared.Peers, id2) {
|
||||
shared.Peers = append(shared.Peers, id2)
|
||||
if shared.AllowedPeersGroup == nil {
|
||||
shared.AllowedPeersGroup = map[string][]string{}
|
||||
}
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), shared.Serialize(), id, caller)
|
||||
if config.GetConfig().Whitelist && len(res) == 0 {
|
||||
shared.AllowedPeersGroup[id2] = []string{"*"}
|
||||
} else {
|
||||
shared.AllowedPeersGroup[id2] = res
|
||||
}
|
||||
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, caller).UpdateOne(
|
||||
shared.Serialize(shared), id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@@ -280,16 +329,17 @@ func (o *CollaborativeAreaController) AddPeer() {
|
||||
// @Success 200 {shared workspace} models.shared_workspace
|
||||
// @router /:id/rule/:id2 [post]
|
||||
func (o *CollaborativeAreaController) AddRule() {
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
|
||||
caller.Disabled = oclib.IsQueryParamsEquals(o.Ctx.Input, "is_remote", true)
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
id2 := o.Ctx.Input.Param(":id2")
|
||||
r := oclib.LoadOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), id)
|
||||
r := oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, nil).LoadOne(id)
|
||||
shared := r.ToCollaborativeArea()
|
||||
if shared != nil && !slices.Contains(shared.Rules, id2) {
|
||||
shared.Rules = append(shared.Rules, id2)
|
||||
}
|
||||
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), shared.Serialize(), id, caller)
|
||||
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, caller).UpdateOne(shared.Serialize(shared), id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@@ -299,9 +349,10 @@ func (o *CollaborativeAreaController) AddRule() {
|
||||
// @Success 200 {shared workspace} delete success!
|
||||
// @router /:id [delete]
|
||||
func (o *CollaborativeAreaController) Delete() {
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
|
||||
caller.Disabled = oclib.IsQueryParamsEquals(o.Ctx.Input, "is_remote", true)
|
||||
o.Data["json"] = oclib.DeleteOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), id, caller)
|
||||
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, caller).DeleteOne(id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@@ -15,12 +15,15 @@ type RuleController struct {
|
||||
// @Title Search
|
||||
// @Description search rule
|
||||
// @Param search path string true "the word search you want to get"
|
||||
// @Param is_draft query string false "draft wished"
|
||||
// @Success 200 {rule} models.rule
|
||||
// @router /search/:search [get]
|
||||
func (o *RuleController) Search() {
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
// store and return Id or post with UUID
|
||||
search := o.Ctx.Input.Param(":search")
|
||||
o.Data["json"] = oclib.Search(nil, search, oclib.LibDataEnum(oclib.RULE))
|
||||
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.ServeJSON()
|
||||
}
|
||||
|
||||
@@ -31,11 +34,12 @@ func (o *RuleController) Search() {
|
||||
// @Success 200 {rule} models.rule
|
||||
// @router /:id [put]
|
||||
func (o *RuleController) Put() {
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
// store and return ID or post with UUID
|
||||
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.RULE), res, id)
|
||||
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.RULE), user, peerID, groups, nil).UpdateOne(res, id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@@ -45,18 +49,22 @@ func (o *RuleController) Put() {
|
||||
// @Success 200 {rule} models.rule
|
||||
// @router / [post]
|
||||
func (o *RuleController) Post() {
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
var res map[string]interface{}
|
||||
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
||||
o.Data["json"] = oclib.StoreOne(oclib.LibDataEnum(oclib.RULE), res)
|
||||
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.RULE), user, peerID, groups, nil).StoreOne(res)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title GetAll
|
||||
// @Description find rule by id
|
||||
// @Param is_draft query string false "draft wished"
|
||||
// @Success 200 {rule} models.rule
|
||||
// @router / [get]
|
||||
func (o *RuleController) GetAll() {
|
||||
o.Data["json"] = oclib.LoadAll(oclib.LibDataEnum(oclib.RULE))
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
isDraft := o.Ctx.Input.Query("is_draft")
|
||||
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.RULE), user, peerID, groups, nil).LoadAll(isDraft == "true")
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@@ -66,8 +74,9 @@ func (o *RuleController) GetAll() {
|
||||
// @Success 200 {rule} models.rule
|
||||
// @router /:id [get]
|
||||
func (o *RuleController) Get() {
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
o.Data["json"] = oclib.LoadOne(oclib.LibDataEnum(oclib.RULE), id)
|
||||
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.RULE), user, peerID, groups, nil).LoadOne(id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@@ -77,7 +86,8 @@ func (o *RuleController) Get() {
|
||||
// @Success 200 {rule} delete success!
|
||||
// @router /:id [delete]
|
||||
func (o *RuleController) Delete() {
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
o.Data["json"] = oclib.DeleteOne(oclib.LibDataEnum(oclib.RULE), id)
|
||||
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.RULE), user, peerID, groups, nil).DeleteOne(id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@@ -15,7 +15,10 @@ type VersionController struct {
|
||||
// @Success 200
|
||||
// @router / [get]
|
||||
func (c *VersionController) GetAll() {
|
||||
c.Data["json"] = map[string]string{"version": "1"}
|
||||
c.Data["json"] = map[string]string{
|
||||
"service": "oc-shared",
|
||||
"version": "1",
|
||||
}
|
||||
c.ServeJSON()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
version: '3.4'
|
||||
|
||||
services:
|
||||
mongo:
|
||||
image: 'mongo:latest'
|
||||
networks:
|
||||
- catalog
|
||||
ports:
|
||||
- 27017:27017
|
||||
container_name: mongo
|
||||
volumes:
|
||||
- oc-catalog-data:/data/db
|
||||
- oc-catalog-data:/data/configdb
|
||||
|
||||
mongo-express:
|
||||
image: "mongo-express:latest"
|
||||
restart: always
|
||||
depends_on:
|
||||
- mongo
|
||||
networks:
|
||||
- catalog
|
||||
ports:
|
||||
- 8081:8081
|
||||
environment:
|
||||
- ME_CONFIG_BASICAUTH_USERNAME=test
|
||||
- ME_CONFIG_BASICAUTH_PASSWORD=test
|
||||
|
||||
volumes:
|
||||
oc-catalog-data:
|
||||
|
||||
networks:
|
||||
catalog:
|
||||
external: true
|
||||
# name: catalog
|
||||
@@ -11,13 +11,15 @@ services:
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.shared.entrypoints=web"
|
||||
- "traefik.http.routers.shared.rule=PathPrefix(/shared)"
|
||||
- "traefik.http.middlewares.auth.forwardauth.address=http://oc-auth:8080/oc/forward"
|
||||
- "traefik.http.routers.shared.tls=false"
|
||||
- "traefik.http.routers.shared.middlewares=auth"
|
||||
- "traefik.http.routers.shared.rule=PathPrefix(`/shared`)"
|
||||
- "traefik.http.middlewares.shared-rewrite.replacepathregex.regex=^/shared(.*)"
|
||||
- "traefik.http.middlewares.shared-rewrite.replacepathregex.replacement=/oc$$1"
|
||||
- "traefik.http.routers.shared.middlewares=shared-rewrite"
|
||||
- "traefik.http.services.shared.loadbalancer.server.port=8080"
|
||||
- "traefik.http.middlewares.shared.forwardauth.address=http://oc-auth:8080/oc/forward"
|
||||
networks:
|
||||
- catalog
|
||||
- oc
|
||||
|
||||
networks:
|
||||
catalog:
|
||||
oc:
|
||||
external: true
|
||||
4
env.env
Normal file
4
env.env
Normal file
@@ -0,0 +1,4 @@
|
||||
KUBERNETES_SERVICE_HOST=192.168.1.169
|
||||
KUBE_CA="LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJkekNDQVIyZ0F3SUJBZ0lCQURBS0JnZ3Foa2pPUFFRREFqQWpNU0V3SHdZRFZRUUREQmhyTTNNdGMyVnkKZG1WeUxXTmhRREUzTWpNeE1USXdNell3SGhjTk1qUXdPREE0TVRBeE16VTJXaGNOTXpRd09EQTJNVEF4TXpVMgpXakFqTVNFd0h3WURWUVFEREJock0zTXRjMlZ5ZG1WeUxXTmhRREUzTWpNeE1USXdNell3V1RBVEJnY3Foa2pPClBRSUJCZ2dxaGtqT1BRTUJCd05DQUFTVlk3ZHZhNEdYTVdkMy9jMlhLN3JLYjlnWXgyNSthaEE0NmkyNVBkSFAKRktQL2UxSVMyWVF0dzNYZW1TTUQxaStZdzJSaVppNUQrSVZUamNtNHdhcnFvMEl3UURBT0JnTlZIUThCQWY4RQpCQU1DQXFRd0R3WURWUjBUQVFIL0JBVXdBd0VCL3pBZEJnTlZIUTRFRmdRVWtlUVJpNFJiODduME5yRnZaWjZHClc2SU55NnN3Q2dZSUtvWkl6ajBFQXdJRFNBQXdSUUlnRXA5ck04WmdNclRZSHYxZjNzOW5DZXZZeWVVa3lZUk4KWjUzazdoaytJS1FDSVFDbk05TnVGKzlTakIzNDFacGZ5ays2NEpWdkpSM3BhcmVaejdMd2lhNm9kdz09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K"
|
||||
KUBE_CERT="LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJrVENDQVRlZ0F3SUJBZ0lJWUxWNkFPQkdrU1F3Q2dZSUtvWkl6ajBFQXdJd0l6RWhNQjhHQTFVRUF3d1kKYXpOekxXTnNhV1Z1ZEMxallVQXhOekl6TVRFeU1ETTJNQjRYRFRJME1EZ3dPREV3TVRNMU5sb1hEVEkxTURndwpPREV3TVRNMU5sb3dNREVYTUJVR0ExVUVDaE1PYzNsemRHVnRPbTFoYzNSbGNuTXhGVEFUQmdOVkJBTVRESE41CmMzUmxiVHBoWkcxcGJqQlpNQk1HQnlxR1NNNDlBZ0VHQ0NxR1NNNDlBd0VIQTBJQUJGQ2Q1MFdPeWdlQ2syQzcKV2FrOWY4MVAvSkJieVRIajRWOXBsTEo0ck5HeHFtSjJOb2xROFYxdUx5RjBtOTQ2Nkc0RmRDQ2dqaXFVSk92Swp3NVRPNnd5alNEQkdNQTRHQTFVZER3RUIvd1FFQXdJRm9EQVRCZ05WSFNVRUREQUtCZ2dyQmdFRkJRY0RBakFmCkJnTlZIU01FR0RBV2dCVFJkOFI5cXVWK2pjeUVmL0ovT1hQSzMyS09XekFLQmdncWhrak9QUVFEQWdOSUFEQkYKQWlFQTArbThqTDBJVldvUTZ0dnB4cFo4NVlMalF1SmpwdXM0aDdnSXRxS3NmUVVDSUI2M2ZNdzFBMm5OVWU1TgpIUGZOcEQwSEtwcVN0Wnk4djIyVzliYlJUNklZCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0KLS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJlRENDQVIyZ0F3SUJBZ0lCQURBS0JnZ3Foa2pPUFFRREFqQWpNU0V3SHdZRFZRUUREQmhyTTNNdFkyeHAKWlc1MExXTmhRREUzTWpNeE1USXdNell3SGhjTk1qUXdPREE0TVRBeE16VTJXaGNOTXpRd09EQTJNVEF4TXpVMgpXakFqTVNFd0h3WURWUVFEREJock0zTXRZMnhwWlc1MExXTmhRREUzTWpNeE1USXdNell3V1RBVEJnY3Foa2pPClBRSUJCZ2dxaGtqT1BRTUJCd05DQUFRc3hXWk9pbnIrcVp4TmFEQjVGMGsvTDF5cE01VHAxOFRaeU92ektJazQKRTFsZWVqUm9STW0zNmhPeVljbnN3d3JoNnhSUnBpMW5RdGhyMzg0S0Z6MlBvMEl3UURBT0JnTlZIUThCQWY4RQpCQU1DQXFRd0R3WURWUjBUQVFIL0JBVXdBd0VCL3pBZEJnTlZIUTRFRmdRVTBYZkVmYXJsZm8zTWhIL3lmemx6Cnl0OWlqbHN3Q2dZSUtvWkl6ajBFQXdJRFNRQXdSZ0loQUxJL2dNYnNMT3MvUUpJa3U2WHVpRVMwTEE2cEJHMXgKcnBlTnpGdlZOekZsQWlFQW1wdjBubjZqN3M0MVI0QzFNMEpSL0djNE53MHdldlFmZWdEVGF1R2p3cFk9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K"
|
||||
KUBE_DATA="LS0tLS1CRUdJTiBFQyBQUklWQVRFIEtFWS0tLS0tCk1IY0NBUUVFSU5ZS1BFb1dhd1NKUzJlRW5oWmlYMk5VZlY1ZlhKV2krSVNnV09TNFE5VTlvQW9HQ0NxR1NNNDkKQXdFSG9VUURRZ0FFVUozblJZN0tCNEtUWUx0WnFUMS96VS84a0Z2Sk1lUGhYMm1Vc25pczBiR3FZblkyaVZEeApYVzR2SVhTYjNqcm9iZ1YwSUtDT0twUWs2OHJEbE03ckRBPT0KLS0tLS1FTkQgRUMgUFJJVkFURSBLRVktLS0tLQo="
|
||||
7
go.mod
7
go.mod
@@ -5,12 +5,13 @@ go 1.22.0
|
||||
toolchain go1.22.4
|
||||
|
||||
require (
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250108155542-0f4adeea86be
|
||||
github.com/beego/beego/v2 v2.3.4
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250219142942-5111c9c8bec7
|
||||
github.com/beego/beego/v2 v2.3.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/biter777/countries v1.7.5 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.6 // indirect
|
||||
@@ -37,7 +38,7 @@ require (
|
||||
github.com/prometheus/client_model v0.6.1 // indirect
|
||||
github.com/prometheus/common v0.60.1 // indirect
|
||||
github.com/prometheus/procfs v0.15.1 // indirect
|
||||
github.com/robfig/cron/v3 v3.0.1 // indirect
|
||||
github.com/robfig/cron v1.2.0 // indirect
|
||||
github.com/rogpeppe/go-internal v1.11.0 // indirect
|
||||
github.com/rs/zerolog v1.33.0 // indirect
|
||||
github.com/shiena/ansicolor v0.0.0-20230509054315-a9deabde6e02 // indirect
|
||||
|
||||
38
go.sum
38
go.sum
@@ -1,12 +1,38 @@
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250108155542-0f4adeea86be h1:1Yf8ihUxXjOEPqcfgtXJpJ/slxBUHhf7AgS7DZI3iUk=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250108155542-0f4adeea86be/go.mod h1:ya7Q+zHhaKM+XF6sAJ+avqHEVzaMnFJQih2X3TlTlGo=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250205160221-88b7cfe2fd0f h1:6V+Z81ywYoDYSVMnM4PVaJYXFgCN3xSG3ddiUPn4jL8=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250205160221-88b7cfe2fd0f/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250213093249-c53e25e69a7b h1:HAb2h0011mE3QrHdOwJCua5w0r/BDOFLNb/557ZAzL0=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250213093249-c53e25e69a7b/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250217072519-cafadec1469f h1:esLB0EAn8IuOChW35kcBrPaN80z4A4yYyz1mXT45GQo=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250217072519-cafadec1469f/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250218080121-a098f0a672ee h1:UIGIiE+O5LUrP18C8nrZxN1v6Lmzfdlv8pvHnSLKJz8=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250218080121-a098f0a672ee/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250218085355-6e6ed4ea2c64 h1:dANQHoMCyp3uioCHnUOpLFiG/UO+biyPUoSelDNJ814=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250218085355-6e6ed4ea2c64/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250218092508-b771b5d25ee5 h1:EwoctMKdVG1PJHRcBcRKCxgdAxy+TV1T617vxIZwkio=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250218092508-b771b5d25ee5/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250218101140-6bf058ab5ca4 h1:7om8VD4ZivHA2BKBwvqM98/a7D+MTwppd2FloNBg1Y4=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250218101140-6bf058ab5ca4/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250218113916-04f7537066c1 h1:on0zLtHo1Jj6FvQ/wuJCc/sxfBfgrd2qTFknpDh3wQM=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250218113916-04f7537066c1/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250218115549-81d3406305c5 h1:DP/XYrxSOc5ORMGvVNqTvFjxLF4cymUW/d3HIZXKDEk=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250218115549-81d3406305c5/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250218130229-7c30633bded0 h1:3EsRmeTz6OWHJETrPObctnGF8WgZtXHfwL2cjyHcfOk=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250218130229-7c30633bded0/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250219075511-241c6a5a0861 h1:XqTFKSZ8hXGCJbuu/SBwakpftevg1AKV7hDI50cXNUg=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250219075511-241c6a5a0861/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250219100312-b4a176667754 h1:7J5EUe/iNS6cT6KVDklpgGH7ak30iEFgWJDEPF6wik4=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250219100312-b4a176667754/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250219104152-3ecb0e9d960b h1:DhRqJdw2VePaYVlsh8OUA3zl+76Q0FWwGu+a+3aOf6s=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250219104152-3ecb0e9d960b/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250219142942-5111c9c8bec7 h1:fh6SzBPenzIxufIIzExtx4jEE4OhFposqn3EbHFr92Q=
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250219142942-5111c9c8bec7/go.mod h1:2roQbUpv3a6mTIr5oU1ux31WbN8YucyyQvCQ0FqwbcE=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/beego/beego/v2 v2.3.1 h1:7MUKMpJYzOXtCUsTEoXOxsDV/UcHw6CPbaWMlthVNsc=
|
||||
github.com/beego/beego/v2 v2.3.1/go.mod h1:5cqHsOHJIxkq44tBpRvtDe59GuVRVv/9/tyVDxd5ce4=
|
||||
github.com/beego/beego/v2 v2.3.4 h1:HurQEOGIEhLlPFCTR6ZDuQkybrUl2Ag2i6CdVD2rGiI=
|
||||
github.com/beego/beego/v2 v2.3.4/go.mod h1:5cqHsOHJIxkq44tBpRvtDe59GuVRVv/9/tyVDxd5ce4=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/biter777/countries v1.7.5 h1:MJ+n3+rSxWQdqVJU8eBy9RqcdH6ePPn4PJHocVWUa+Q=
|
||||
github.com/biter777/countries v1.7.5/go.mod h1:1HSpZ526mYqKJcpT5Ti1kcGQ0L0SrXWIaptUWjFfv2E=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/coreos/etcd v3.3.17+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
@@ -97,8 +123,8 @@ github.com/prometheus/common v0.60.1 h1:FUas6GcOw66yB/73KC+BOZoFJmbo/1pojoILArPA
|
||||
github.com/prometheus/common v0.60.1/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw=
|
||||
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
||||
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
||||
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
||||
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||
github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ=
|
||||
github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k=
|
||||
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
|
||||
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
|
||||
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
|
||||
19
main.go
19
main.go
@@ -11,8 +11,26 @@ import (
|
||||
const appname = "oc-shared"
|
||||
|
||||
func main() {
|
||||
// Init the oc-lib
|
||||
// Init the oc-lib
|
||||
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"},
|
||||
@@ -20,5 +38,6 @@ func main() {
|
||||
ExposeHeaders: []string{"Content-Length", "Content-Type"},
|
||||
AllowCredentials: true,
|
||||
}))
|
||||
|
||||
beego.Run()
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"port":8080,
|
||||
"port":8091,
|
||||
"MONGO_URL":"mongodb://localhost:27017/",
|
||||
"MONGO_DATABASE":"DC_myDC"
|
||||
}
|
||||
@@ -22,6 +22,14 @@
|
||||
],
|
||||
"description": "find shared workspace by id\n\u003cbr\u003e",
|
||||
"operationId": "CollaborativeAreaController.GetAll",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "query",
|
||||
"name": "is_draft",
|
||||
"description": "draft wished",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "{shared_workspace} models.shared_workspace"
|
||||
@@ -66,6 +74,12 @@
|
||||
"description": "the word search you want to get",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"in": "query",
|
||||
"name": "is_draft",
|
||||
"description": "draft wished",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
@@ -170,6 +184,15 @@
|
||||
"description": "the id you want to add",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"in": "body",
|
||||
"name": "body",
|
||||
"description": "The shared workspace content",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/models.workspace"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
@@ -357,7 +380,7 @@
|
||||
"collaborative_area"
|
||||
],
|
||||
"description": "find shared workspace by id\n\u003cbr\u003e",
|
||||
"operationId": "CollaborativeAreaController.Add Workspace",
|
||||
"operationId": "CollaborativeAreaController.Remove Workspace",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "path",
|
||||
|
||||
@@ -20,6 +20,11 @@ paths:
|
||||
find shared workspace by id
|
||||
<br>
|
||||
operationId: CollaborativeAreaController.GetAll
|
||||
parameters:
|
||||
- in: query
|
||||
name: is_draft
|
||||
description: draft wished
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: '{shared_workspace} models.shared_workspace'
|
||||
@@ -114,6 +119,12 @@ paths:
|
||||
description: the id you want to add
|
||||
required: true
|
||||
type: string
|
||||
- in: body
|
||||
name: body
|
||||
description: The shared workspace content
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/models.workspace'
|
||||
responses:
|
||||
"200":
|
||||
description: '{shared workspace} models.shared_workspace'
|
||||
@@ -252,7 +263,7 @@ paths:
|
||||
description: |-
|
||||
find shared workspace by id
|
||||
<br>
|
||||
operationId: CollaborativeAreaController.Add Workspace
|
||||
operationId: CollaborativeAreaController.Remove Workspace
|
||||
parameters:
|
||||
- in: path
|
||||
name: id
|
||||
@@ -281,6 +292,10 @@ paths:
|
||||
description: the word search you want to get
|
||||
required: true
|
||||
type: string
|
||||
- in: query
|
||||
name: is_draft
|
||||
description: draft wished
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: '{shared workspace} models.shared_workspace'
|
||||
|
||||
Reference in New Issue
Block a user