feature: dynamic scope using input arguments #23

Merged
xdrm-brackets merged 4 commits from feature/dynamic-scope into 0.3.0 2021-05-19 12:06:20 +00:00
1 changed files with 7 additions and 4 deletions
Showing only changes of commit c35e2fdd9a - Show all commits

View File

@ -59,11 +59,14 @@ func (s Handler) resolve(w http.ResponseWriter, r *http.Request) {
for b, perm := range list {
scope[a][b] = perm
for name, value := range input.Data {
scope[a][b] = strings.ReplaceAll(
scope[a][b],
fmt.Sprintf("[%s]", name),
fmt.Sprintf("[%v]", value),
var (
token = fmt.Sprintf("[%s]", name)
replacement = ""
)
if value != nil {
replacement = fmt.Sprintf("[%v]", value)
}
scope[a][b] = strings.ReplaceAll(scope[a][b], token, replacement)
}
}
}