Skip to content

Commit

Permalink
Add support for API config_data to Coprocess middleware
Browse files Browse the repository at this point in the history
Spec object now have new key `config_data` which contains JSON string
representation of `APIDefinition.ConfigData`

Fix #1197
  • Loading branch information
buger committed Dec 7, 2017
1 parent cc83249 commit 4d8fa62
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions coprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package main

import (
"encoding/json"
"strings"

"github.com/Sirupsen/logrus"
Expand Down Expand Up @@ -107,9 +108,15 @@ func (c *CoProcessor) ObjectFromRequest(r *http.Request) *coprocess.Object {

// Append spec data:
if c.Middleware != nil {
configDataAsJson := []byte("{}")
if len(c.Middleware.Spec.ConfigData) > 0 {
configDataAsJson, _ = json.Marshal(c.Middleware.Spec.ConfigData)
}

object.Spec = map[string]string{
"OrgID": c.Middleware.Spec.OrgID,
"APIID": c.Middleware.Spec.APIID,
"OrgID": c.Middleware.Spec.OrgID,
"APIID": c.Middleware.Spec.APIID,
"config_data": string(configDataAsJson),
}
}

Expand Down

0 comments on commit 4d8fa62

Please sign in to comment.