Fix API inconsistencies (#404)

* fix api inconsistencies

* handling empty format cases

* code style
This commit is contained in:
Pedro Nasser
2016-12-07 17:16:48 -02:00
committed by GitHub
parent b990cba1df
commit 5367a3ef99
8 changed files with 42 additions and 23 deletions

View File

@@ -345,8 +345,12 @@ func (ds *BoltDatastore) UpdateRoute(ctx context.Context, newroute *models.Route
if newroute.Timeout != 0 {
route.Timeout = newroute.Timeout
}
route.Format = newroute.Format
route.MaxConcurrency = newroute.MaxConcurrency
if newroute.Format != "" {
route.Format = newroute.Format
}
if newroute.MaxConcurrency != 0 {
route.MaxConcurrency = newroute.MaxConcurrency
}
if newroute.Headers != nil {
if route.Headers == nil {
route.Headers = map[string][]string{}
@@ -364,6 +368,10 @@ func (ds *BoltDatastore) UpdateRoute(ctx context.Context, newroute *models.Route
}
}
if err := route.Validate(); err != nil {
return err
}
buf, err := json.Marshal(route)
if err != nil {
return err