Refactor service template.

This commit is contained in:
John Beisley 2022-06-08 07:05:49 +01:00
parent ef53d14055
commit 9b16826229

View File

@ -1,5 +1,5 @@
{{define "service"}} {{define "service"}}
{{- $Imps := .Imps}} {{- $Imps := .Imps -}}
package {{.Manifest.Package}} package {{.Manifest.Package}}
import ( import (
@ -13,18 +13,19 @@ import (
{{end}} {{end}}
{{define "action"}} {{define "action"}}
type {{.Action.Name}}Request struct { {{- $Imps := .Imps}}
{{- template "args" args "Args" .Action.InArgs "Imps" .Imps}} type {{.Action.Name}}Request struct
} {{- template "args" args "Args" .Action.InArgs "Imps" $Imps}}
type {{.Action.Name}}Response struct { type {{.Action.Name}}Response struct
{{- template "args" args "Args" .Action.OutArgs "Imps" .Imps}} {{- template "args" args "Args" .Action.OutArgs "Imps" $Imps}}
}
{{- end}} {{- end}}
{{define "args"}} {{define "args"}}
{{- $Imps := .Imps}} {{- $Imps := .Imps -}}
{{- range .Args}} { {{- with .Args}}
{{- range .}}
{{.Name}} {{index $Imps.TypeRefByTypeName .RelatedStateVariable.DataType}} {{.Name}} {{index $Imps.TypeRefByTypeName .RelatedStateVariable.DataType}}
{{- end}} {{- end}}
{{end -}} }
{{- end}} {{- end}}