Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
perxis-go
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package Registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
perxis
perxis-go
Commits
18f98d06
Commit
18f98d06
authored
1 year ago
by
Anton Sattarov
Committed by
Pavel Antonov
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Добавлена функция получения метаданных из запроса к actions
parent
ba6ead1a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pkg/extension/action.go
+28
-1
28 additions, 1 deletion
pkg/extension/action.go
pkg/references/reference.go
+18
-0
18 additions, 0 deletions
pkg/references/reference.go
with
46 additions
and
1 deletion
pkg/extension/action.go
+
28
−
1
View file @
18f98d06
package
extension
import
(
"strings"
"git.perx.ru/perxis/perxis-go/pkg/references"
pb
"git.perx.ru/perxis/perxis-go/proto/extensions"
"github.com/mitchellh/mapstructure"
...
...
@@ -116,7 +118,7 @@ func ActionToMap(action *Action) map[string]interface{} {
if
action
==
nil
{
return
nil
}
res
:=
make
(
map
[
string
]
interface
{})
if
err
:=
mapstructure
.
Decode
(
action
,
&
res
);
err
!=
nil
{
return
nil
...
...
@@ -274,3 +276,28 @@ func ActionToPB(a *Action) *pb.Action {
Order
:
a
.
Order
,
}
}
func
(
r
*
ActionRequest
)
NewSubRequest
()
*
ActionRequest
{
md
:=
map
[
string
]
string
{
"request_extension"
:
r
.
Extension
,
"request_action"
:
r
.
Action
,
"request_space_id"
:
r
.
SpaceID
,
"request_env_id"
:
r
.
EnvID
,
"request_collection_id"
:
r
.
CollectionID
,
"request_item_id"
:
r
.
ItemID
,
"request_item_ids"
:
strings
.
Join
(
r
.
ItemIDs
,
","
),
"request_fields"
:
strings
.
Join
(
r
.
Fields
,
","
),
"request_refs"
:
references
.
ReferenceListToString
(
r
.
Refs
),
"request_params"
:
r
.
Params
.
String
(),
}
for
k
,
v
:=
range
r
.
Metadata
{
if
_
,
exist
:=
md
[
k
];
!
exist
{
md
[
k
]
=
v
}
}
return
&
ActionRequest
{
Metadata
:
md
,
}
}
This diff is collapsed.
Click to expand it.
pkg/references/reference.go
+
18
−
0
View file @
18f98d06
package
references
import
(
"strings"
"git.perx.ru/perxis/perxis-go/pkg/items"
pb
"git.perx.ru/perxis/perxis-go/proto/references"
"go.mongodb.org/mongo-driver/bson"
...
...
@@ -82,6 +84,22 @@ func ReferenceListToPB(refs []*Reference) []*pb.Reference {
return
list
}
func
ReferenceListToString
(
refs
[]
*
Reference
)
string
{
var
res
strings
.
Builder
for
_
,
ref
:=
range
refs
{
res
.
WriteString
(
ref
.
String
())
}
return
res
.
String
()
}
func
ReferenceListToStrings
(
refs
[]
*
Reference
)
(
res
[]
string
)
{
for
_
,
ref
:=
range
refs
{
res
=
append
(
res
,
ref
.
String
())
}
return
}
func
(
r
*
Reference
)
String
()
string
{
if
r
==
nil
{
return
""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment