add aditional check for nil message passed

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2021-03-24 10:44:53 +03:00
parent 2bb1299e56
commit 1bbdf03f60
2 changed files with 15 additions and 7 deletions

View File

@@ -28,6 +28,10 @@ func newPathRequest(path string, method string, body string, msg interface{}, ta
return "", nil, err
}
if len(tpl.Fields) > 0 && msg == nil {
return "", nil, fmt.Errorf("nil message but path params requested: %v", path)
}
fieldsmap := make(map[string]string, len(tpl.Fields))
for _, v := range tpl.Fields {
fieldsmap[v] = ""
@@ -95,7 +99,7 @@ func newPathRequest(path string, method string, body string, msg interface{}, ta
// check not filled stuff
for k, v := range fieldsmap {
if v == "" {
return "", nil, fmt.Errorf("path param %s not filled %s", k, v)
return "", nil, fmt.Errorf("path param %s not filled", k)
}
}