goupnp/v2alpha/srv/srv.gotemplate
2022-06-08 07:05:49 +01:00

32 lines
689 B
Plaintext

{{define "service"}}
{{- $Imps := .Imps -}}
package {{.Manifest.Package}}
import (
{{- range .Imps.ImportLines}}
{{quote .Alias}} {{.Path}}
{{- end}}
)
{{range .SCPD.SortedActions}}
{{- template "action" args "Action" . "Imps" $Imps}}
{{end}}
{{end}}
{{define "action"}}
{{- $Imps := .Imps}}
type {{.Action.Name}}Request struct
{{- template "args" args "Args" .Action.InArgs "Imps" $Imps}}
type {{.Action.Name}}Response struct
{{- template "args" args "Args" .Action.OutArgs "Imps" $Imps}}
{{- end}}
{{define "args"}}
{{- $Imps := .Imps -}}
{ {{- with .Args}}
{{- range .}}
{{.Name}} {{index $Imps.TypeRefByTypeName .RelatedStateVariable.DataType}}
{{- end}}
{{end -}} }
{{- end}}