only add api endpoint metadata if it exists (#1087)
This commit is contained in:
parent
be6e8a7c78
commit
1892bd05a5
25
api/api.go
25
api/api.go
@ -57,14 +57,25 @@ func Encode(e *Endpoint) map[string]string {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return map[string]string{
|
// endpoint map
|
||||||
"endpoint": e.Name,
|
ep := make(map[string]string)
|
||||||
"description": e.Description,
|
|
||||||
"method": strings.Join(e.Method, ","),
|
// set vals only if they exist
|
||||||
"path": strings.Join(e.Path, ","),
|
set := func(k, v string) {
|
||||||
"host": strings.Join(e.Host, ","),
|
if len(v) == 0 {
|
||||||
"handler": e.Handler,
|
return
|
||||||
}
|
}
|
||||||
|
ep[k] = v
|
||||||
|
}
|
||||||
|
|
||||||
|
set("endpoint", e.Name)
|
||||||
|
set("description", e.Description)
|
||||||
|
set("handler", e.Handler)
|
||||||
|
set("method", strings.Join(e.Method, ","))
|
||||||
|
set("path", strings.Join(e.Path, ","))
|
||||||
|
set("host", strings.Join(e.Host, ","))
|
||||||
|
|
||||||
|
return ep
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode decodes endpoint metadata into an endpoint
|
// Decode decodes endpoint metadata into an endpoint
|
||||||
|
Loading…
Reference in New Issue
Block a user