From af625ae788423198e758511fe2ce5f49d23547f8 Mon Sep 17 00:00:00 2001 From: Akshay Gadikar Date: Wed, 6 Feb 2019 14:19:11 -0800 Subject: [PATCH 1/7] 1. Adding circuit breaker configurations 2. Support for POST, PUT and PATCH methods --- examples/api/default-http-pattern/main.go | 6 +++ internal/pattern/DefaultHttpPattern.json | 49 +++++++++++++++++++---- internal/pattern/assets.go | 10 +++-- 3 files changed, 54 insertions(+), 11 deletions(-) diff --git a/examples/api/default-http-pattern/main.go b/examples/api/default-http-pattern/main.go index 2dff584..7aaf787 100644 --- a/examples/api/default-http-pattern/main.go +++ b/examples/api/default-http-pattern/main.go @@ -84,6 +84,12 @@ func main() { "jwtSub": "tempuser@mail.com", "useCircuitBreaker": true, "backendUrl": "http://localhost:1234/pets", + "mode": "a", + "threshold": 5, + "timeout": 60, + "period": 60, + "method": "GET", + "payload": "", }) if err != nil { panic(err) diff --git a/internal/pattern/DefaultHttpPattern.json b/internal/pattern/DefaultHttpPattern.json index ca13554..b272ac0 100644 --- a/internal/pattern/DefaultHttpPattern.json +++ b/internal/pattern/DefaultHttpPattern.json @@ -25,9 +25,17 @@ "service": "CircuitBreaker" }, { - "if": "$.conf.useJWT == false || $.JWTValidator.outputs.valid == true", - "service": "HttpBackend", - "halt": "($.HttpBackend.error != nil) && !error.isneterror($.HttpBackend.error)" + "if": "($.conf.useJWT == false || $.JWTValidator.outputs.valid == true) && $.conf.method == 'GET'" , + "service": "HttpBackendA", + "halt": "($.HttpBackendA.error != nil) && !error.isneterror($.HttpBackendA.error)" + }, + { + "if": "($.conf.useJWT == false || $.JWTValidator.outputs.valid == true) && ($.conf.method == 'PUT' || $.conf.method == 'POST' || $.conf.method == 'PATCH')", + "service": "HttpBackendB", + "input": { + "content": "=$.conf.payload" + }, + "halt": "($.HttpBackendB.error != nil) && !error.isneterror($.HttpBackendB.error)" }, { "if": "$.conf.useCircuitBreaker == true && $.HttpBackend.error != nil", @@ -77,10 +85,25 @@ } }, { + "if": "$.HttpBackendA.outputs.data != ''", "error": false, "output": { "code": 200, - "data": "=$.HttpBackend.outputs.data" + "data": "=$.HttpBackendA.outputs.data" + } + }, + { + "if": "$.HttpBackendB.outputs.data != ''", + "error": false, + "output": { + "code": 200, + "data": "=$.HttpBackendB.outputs.data" + } + }, + { + "error": false, + "output": { + "code": 200 } } ], @@ -103,15 +126,27 @@ "description": "Circuit breaker service", "ref": "github.com/project-flogo/microgateway/activity/circuitbreaker", "settings": { - "mode": "a" + "mode": "=$.conf.mode", + "threshold": "=$.conf.threshold", + "timeout": "=$.conf.timeout", + "period": "=$.conf.period" + } + }, + { + "name": "HttpBackendA", + "description": "Make an http call to your backend", + "ref": "github.com/project-flogo/contrib/activity/rest", + "settings": { + "method": "=$.conf.method", + "uri": "=$.conf.backendUrl" } }, { - "name": "HttpBackend", + "name": "HttpBackendB", "description": "Make an http call to your backend", "ref": "github.com/project-flogo/contrib/activity/rest", "settings": { - "method": "GET", + "method": "=$.conf.method", "uri": "=$.conf.backendUrl" } } diff --git a/internal/pattern/assets.go b/internal/pattern/assets.go index 6200614..ed910aa 100644 --- a/internal/pattern/assets.go +++ b/internal/pattern/assets.go @@ -1,7 +1,9 @@ -// Code generated by go-bindata. DO NOT EDIT. @generated +// Code generated by go-bindata. // sources: // DefaultHttpPattern.json // DefaultChannelPattern.json +// DO NOT EDIT! + package pattern import ( @@ -67,7 +69,7 @@ func (fi bindataFileInfo) Sys() interface{} { return nil } -var _defaulthttppatternJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xbc\x56\x4b\x6f\xdb\x38\x10\xbe\xfb\x57\x4c\x08\x23\xd8\x00\x89\x9c\x7d\x9c\x0c\xf8\x90\x64\x83\xdd\xcd\x36\x40\x91\xba\xcd\xa1\xe8\x81\xa2\xc6\x12\x63\x99\x54\xc9\xa1\x5d\x37\xf1\x7f\x2f\x44\x4b\x8e\xa4\xc8\xb2\x13\x17\xbd\xe4\xc1\x79\x7d\x33\xf3\xcd\x68\x1e\x7b\x00\x4c\xf1\x19\xb2\x21\xb0\xbf\x71\xc2\x5d\x4a\xff\x12\x65\xef\x39\x11\x1a\xc5\x4e\x73\xb9\x25\xcc\x2c\x1b\xc2\xe7\x1e\x00\xc0\xa3\xff\x09\xc0\xe4\x24\x37\xea\x07\x42\xab\x49\xe0\x2c\xde\x71\xc2\x77\x72\x26\x09\x0d\x8c\x46\x40\xc6\xa1\xb7\xf7\xca\x16\xcd\x5c\x0a\x1f\xa6\xa2\xf7\x2c\x97\x2a\x73\xc4\x86\x1b\xef\x00\x8c\xf4\x14\x55\x6e\x10\xa7\x3a\xe4\x29\x2b\x24\x2b\xff\x7b\x75\xda\x0d\xe6\xe6\x7e\xdc\x09\xe2\xe6\x7e\xfc\x89\xa7\x32\xe2\xa4\xf7\x44\x31\xea\x07\x19\x5f\xa6\x9a\x47\x41\x82\x3c\x42\x63\x83\x0b\x47\x89\x36\xf2\x3b\x27\xa9\xd5\xc6\x4b\x1e\x48\xc6\x4a\xaa\xf8\x16\x29\xd1\x51\x61\xec\x91\x3d\x2c\xe8\x43\x4d\x56\x31\x9a\xe2\xb2\xa1\xfa\x3f\x2e\xab\x0a\xdc\x35\x7d\x5d\xb8\x9a\x07\x69\x6d\x43\xe1\x3f\x6b\x6b\xb8\x5c\xd8\x44\xe3\xc2\xd7\x15\xf6\x4a\x1a\xe1\x24\x5d\x1a\xe4\xd3\x1d\x8d\xae\xab\xb2\xd7\xf4\x6d\xc2\x53\x8b\xf0\xf4\x04\xfd\xa0\xda\xa9\x40\x3b\xca\x1c\xd9\x60\x9e\xbf\x74\x06\xcf\x59\x7c\xc9\xc5\x14\xd5\x73\x89\x58\xc2\xd3\xbc\xbd\xec\xb7\x7e\x50\x91\x07\x68\x8c\x36\x70\x34\x02\x25\xd3\x13\x38\x3e\x86\x23\xff\x12\x48\xab\x90\xfc\x9f\x6d\x06\x27\xfb\x65\xd4\x5e\xb0\x3c\xca\x76\x10\xfb\x94\xb3\x8b\xb4\x3a\x43\xb3\x26\xe5\x10\x98\xd0\x4e\x51\x59\xff\xc3\xda\xbc\x0d\xf5\xe8\xe7\xa3\x36\x68\x91\x1a\x98\x7b\x00\x5f\xfc\x46\x32\x68\x33\xad\x2c\x76\x6c\xa5\xca\x96\xd9\xb0\x26\xcd\xff\xbf\x43\x2e\x12\x6c\x21\x8f\x4f\x85\x0d\xfd\xeb\xe6\x71\x6d\x5a\xc7\x29\x74\x94\xa7\xf6\xd7\xf9\x9f\x95\xd1\x8a\x38\xf1\x9a\x9a\x5f\x9c\x9c\x9c\x2d\x77\x1e\x78\x38\x70\xfd\x4d\x20\x46\x18\xc1\x19\x8c\x13\x84\xa2\x54\xb0\xd4\x0e\x12\x3e\x47\x30\xf8\xd5\xa1\x25\x8c\x40\x5a\xd0\x73\x34\x40\x09\x02\x4f\x53\xbd\xc0\x08\x7c\x0a\x01\xdb\x44\x59\xbd\x75\x2b\xae\x5b\xd9\x3d\x5c\x7e\x0a\x0f\x29\xd0\xef\x3b\x0a\xe4\x3d\xde\xa2\xb5\x3c\xc6\x62\x31\xb5\x22\xaa\xe9\x9d\x56\x3d\xcc\xd7\xba\x52\xab\x3d\xdc\xbc\x54\x7e\x63\x1d\xbb\xa6\xa3\x2e\xdb\xc4\x26\x23\xb3\xec\xd7\xd0\xae\xf4\xc8\xc4\x1a\x0a\x84\x05\xce\x02\xc3\xbe\x59\x97\x7e\x3c\x0d\xf6\x81\xf6\xc7\xf9\xf9\x4b\x68\x79\x37\xaa\x1b\xa3\x2c\x88\x17\x6f\x99\xef\x62\x28\x5a\xc6\xbb\xbc\x55\x5a\x8f\x88\x08\xad\x30\x32\x2b\x57\x88\x1f\xba\xb4\xa9\x64\xd0\x37\x33\x96\x94\xb8\x30\x10\x7a\x36\xc8\x8c\x7e\x40\x41\x67\x93\x54\xc7\x7a\x30\x93\xc2\xe8\x98\x13\x2e\xf8\x72\xc0\x05\xc9\xb9\xa4\xe5\xc0\x70\xc2\x17\xae\x2c\x12\x49\x15\xdb\x7a\x31\xbc\x5a\xf5\x33\x6b\x4a\xac\xdd\x2b\xb8\x4c\xad\xfd\x34\x69\xe4\x56\x68\x20\x58\x3d\x43\xf0\x47\x8a\x3d\x34\xc7\x87\x05\xb5\x7f\xd2\x4a\x64\xdb\x76\x79\x03\xdb\x55\x83\x76\xe5\xd7\xe0\x40\x78\x05\x9b\xc3\x66\xf4\xf6\x2e\xcc\xd6\x94\x64\x4d\x8e\x6d\x49\xad\xf5\x5c\x68\xe4\x75\xcb\xa7\x08\x5c\x41\x42\x94\x81\xe0\x69\x0a\xa4\xf3\xbd\x6d\x20\x6c\x5a\xee\xca\x50\x68\x45\x46\x86\x15\x7e\xa1\xa5\x9d\x29\x6d\xce\xc9\x7f\xae\xc7\xd5\xb3\xce\x19\x59\xe5\x5b\x81\xe6\xa3\x69\xde\xcc\xf9\x7c\xf5\x56\xbd\x1f\x01\x00\x00\xff\xff\x3b\xd8\x78\xbf\xf5\x0b\x00\x00") +var _defaulthttppatternJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xe4\x57\x4d\x73\xdb\x36\x10\xbd\xeb\x57\x6c\x38\x9e\x28\x9e\x71\x68\xf7\xe3\xa4\x19\x1d\x2c\x37\xd3\x34\xad\xa7\x99\x44\x69\x0e\x9d\x1e\x20\x72\x25\xc2\x02\x01\x16\x58\xc8\x55\x13\xff\xf7\x0e\x40\x52\x06\x3f\x44\xc9\x76\xeb\x4b\x2f\xb6\x08\x3c\x2c\xde\xbe\x5d\xec\x02\x5f\x46\x00\x91\x64\x39\x46\x13\x88\x7e\xc0\x25\xb3\x82\xde\x12\x15\xef\x19\x11\x6a\x19\x9d\xb9\x79\x43\x58\x98\x68\x02\xbf\x8f\x00\x00\xbe\xf8\xbf\x00\x11\x5f\xba\x45\x27\x71\xa2\xe4\x32\xb6\x06\x3f\x30\xc2\x5f\x78\xce\x09\x35\x4c\xa7\x40\xda\xa2\x5f\xef\xc1\x06\xf5\x86\x27\x7e\x9b\x00\x77\x3f\xcf\x65\x61\x29\x9a\xec\xac\x03\x44\xa4\xd6\x28\xdd\x82\x95\x50\x0b\x26\xa2\x6a\xe6\xce\xff\xbf\x3b\x1b\x26\xf3\xee\xf3\x7c\x90\xc4\xbb\xcf\xf3\xdf\x98\xe0\x29\x23\x75\x24\x8b\xe9\x49\x5c\xb0\xad\x50\x2c\x8d\x33\x64\x29\x6a\x13\x5f\x5a\xca\x94\xe6\x7f\x33\xe2\x4a\xee\xac\xb8\x8d\xf8\x4a\x72\xb9\xba\x46\xca\x54\x5a\x2d\xf6\xcc\x6e\x6e\xe9\x63\x63\x2e\x58\xb4\xc6\x6d\x0b\xfa\x33\x6e\x43\x00\xb3\x6d\x5b\x97\xb6\x61\x81\x1b\xd3\x02\xfc\x64\x4c\x83\x97\x5d\xb4\xd9\xd8\xc5\xc3\x84\xbd\xe2\x3a\xb1\x9c\x66\x1a\xd9\xfa\x40\xa0\x9b\xd0\x68\xc0\xfc\xab\x4e\xe0\x96\x4c\x18\x84\xaf\x5f\xe1\x24\x0e\x43\x15\x2b\x4b\x85\x25\x13\x6f\xdc\x48\xbd\xfb\x29\xbc\x7c\x09\x95\x89\xdc\xeb\xea\x66\xc6\x3f\xbe\x99\x8f\x23\xe8\x63\xe6\x52\x7c\xc6\x92\x35\xca\xf4\xf2\x9e\x7a\xc6\x04\x55\x6c\x42\x40\x8c\x5a\x2b\x0d\x2f\xa6\x20\xb9\xf0\x5b\xbd\xf0\x23\x31\x37\x12\xc9\xff\xec\x5d\x71\xfa\x5f\x7b\xfc\xaa\xeb\xf2\xfb\x4f\xf3\x71\x69\xa3\x33\xf3\xeb\xc7\xbd\x53\x97\xf3\xab\xb7\xe3\xd3\xde\x18\x06\x6e\xcd\x06\xcf\x49\xa2\x24\xa1\xa4\x30\xbd\xaa\xe3\xb2\xcb\xaf\x03\x42\xcf\x1e\x2c\xf4\xec\x08\xa1\x0f\x65\x6e\x99\x3a\x81\xd1\x06\x8b\x63\xf2\x7a\x48\x15\x55\xa0\x2e\xab\xc3\xc4\x49\x64\x25\xd5\x07\xe1\x69\xe7\x6d\x1f\xeb\xe9\xbf\xcf\x5a\xa3\x41\x6a\x71\x1e\x01\xfc\xe1\x5b\x83\x46\x53\x28\x69\x70\xa0\x3d\x04\xe5\x7e\x97\xcb\xc2\x7d\x7f\x40\x96\x64\x98\x76\x4b\x88\x77\x25\x9a\xf8\xd1\xdd\x60\xb9\xb4\x9d\x73\xa9\x73\xed\xfb\x8b\xef\x82\x1a\x97\x32\x62\x0d\x98\xef\x60\x8c\xac\xa9\x9b\x0f\x78\x3a\xf0\xe6\xaf\x04\x31\xc5\x14\x5e\xc3\x3c\x43\xa8\xa4\x82\xad\xb2\x90\xb1\x0d\x82\xc6\x3f\x2d\x1a\xc2\x14\xb8\x01\xb5\x41\x0d\x94\x21\x30\x21\xd4\x2d\xa6\xe0\x5d\x88\xa3\xdd\x2e\x77\x8f\x6d\x4f\x65\x28\x87\x8f\xbc\xaf\x0d\x4f\x11\xe8\x9b\x03\x02\x79\x8b\xd7\x68\x0c\x5b\x61\x75\x84\x7b\x19\x35\x70\x67\xa1\x85\x4d\x89\xe5\x4a\x1e\x61\xa6\x0b\x7e\xa4\x8e\x43\xa7\xa3\x39\xb7\xdb\x9b\x34\x2f\x8a\xe7\x49\xbb\xda\x62\x94\x94\x54\x60\x51\xf1\xac\x38\x3c\xd4\xeb\x46\x8f\xa9\xfd\x71\x1b\xbb\x6a\x35\x1e\x77\x5d\xf1\x79\x73\x8c\x2f\xdf\x5e\x5c\x74\x7d\x71\xe1\xdb\xbb\xe5\x71\x55\xac\x51\xac\x9f\x9d\xf1\xec\x01\x8c\x1f\x43\x60\x4f\x51\xac\x2a\x49\x4f\x4d\xac\x6f\xda\xbd\x57\xe0\x14\x4d\xa2\x79\x51\xd7\x5d\x5f\xa9\x44\x1b\xa4\xd1\x2b\xbb\xe2\x94\xd9\x45\x9c\xa8\xfc\xbc\xd0\xea\x06\x13\x7a\xbd\x14\x6a\xa5\xce\x73\x9e\x68\xb5\x62\x84\xb7\x6c\x7b\xce\x12\xe2\x1b\x4e\xdb\x73\xcd\x08\x3b\xa6\x0c\x12\x71\xb9\x32\x4d\xef\x3c\x2c\xec\xe2\xba\xe6\x3a\xac\x5f\xed\x5a\xff\xc5\xba\xe5\x5b\x85\x40\x30\x2a\x47\xf0\x57\x6c\xf3\x54\x1f\x6f\x6e\xa9\xff\x1e\x50\x33\xdb\xd7\x00\x5b\xdc\xae\x5a\x67\xb5\x6e\xa1\x4f\xa4\x57\x95\x80\x45\x7b\xf7\xfe\x28\xe4\x65\x8e\xed\x82\xe0\xbf\x83\x7c\xa7\x4c\xa3\xc9\x94\x68\x3c\x08\xee\x07\x43\x24\xcf\x51\xd9\x46\x44\xeb\xa1\x00\x55\xa0\xe6\xcd\x97\x4a\x35\x72\x54\xcc\xfb\xaf\xd3\x2d\x5d\xaf\xd9\x1a\x81\x49\xc8\x88\x0a\x48\x98\x10\x40\xca\x35\x5b\x0d\x8b\x72\xe9\xf1\x0a\xbb\xbb\xa6\xe6\x8b\x20\xbf\xd1\xd0\x41\x49\x3b\x8f\xb1\xbc\xf3\x04\xb3\x9a\x87\x80\x8a\xd8\x27\x7d\xe0\xf1\xd9\xa3\xc3\xec\x7f\xa1\x83\x2b\x79\xa3\xbb\xd1\x3f\x01\x00\x00\xff\xff\x98\x3d\x01\x6a\x46\x10\x00\x00") func defaulthttppatternJsonBytes() ([]byte, error) { return bindataRead( @@ -82,7 +84,7 @@ func defaulthttppatternJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "DefaultHttpPattern.json", size: 3061, mode: os.FileMode(420), modTime: time.Unix(1544138209, 0)} + info := bindataFileInfo{name: "DefaultHttpPattern.json", size: 4166, mode: os.FileMode(420), modTime: time.Unix(1549489516, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -102,7 +104,7 @@ func defaultchannelpatternJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "DefaultChannelPattern.json", size: 2184, mode: os.FileMode(420), modTime: time.Unix(1541190653, 0)} + info := bindataFileInfo{name: "DefaultChannelPattern.json", size: 2184, mode: os.FileMode(420), modTime: time.Unix(1549486667, 0)} a := &asset{bytes: bytes, info: info} return a, nil } From 43eb797bed10662576db98d467191046513eee04 Mon Sep 17 00:00:00 2001 From: Akshay Gadikar Date: Thu, 7 Feb 2019 09:55:44 -0800 Subject: [PATCH 2/7] added configurations to flogo-json --- examples/api/default-http-pattern/main.go | 2 +- examples/json/default-http-pattern/flogo.json | 8 +++++++- internal/pattern/DefaultHttpPattern.json | 2 +- internal/pattern/assets.go | 4 ++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/examples/api/default-http-pattern/main.go b/examples/api/default-http-pattern/main.go index 7aaf787..d727a43 100644 --- a/examples/api/default-http-pattern/main.go +++ b/examples/api/default-http-pattern/main.go @@ -89,7 +89,7 @@ func main() { "timeout": 60, "period": 60, "method": "GET", - "payload": "", + "content": "", }) if err != nil { panic(err) diff --git a/examples/json/default-http-pattern/flogo.json b/examples/json/default-http-pattern/flogo.json index d73a847..6e35563 100644 --- a/examples/json/default-http-pattern/flogo.json +++ b/examples/json/default-http-pattern/flogo.json @@ -33,7 +33,13 @@ "jwtIss": "Mashling", "jwtSub": "tempuser@mail.com", "useCircuitBreaker": true, - "backendUrl": "http://localhost:1234/pets" + "backendUrl": "http://localhost:1234/pets", + "mode": "a", + "threshold": 2, + "timeout": 60, + "period": 60, + "method": "POST", + "content": "{\"name\":\"sally\"}" } } ] diff --git a/internal/pattern/DefaultHttpPattern.json b/internal/pattern/DefaultHttpPattern.json index b272ac0..53dc549 100644 --- a/internal/pattern/DefaultHttpPattern.json +++ b/internal/pattern/DefaultHttpPattern.json @@ -33,7 +33,7 @@ "if": "($.conf.useJWT == false || $.JWTValidator.outputs.valid == true) && ($.conf.method == 'PUT' || $.conf.method == 'POST' || $.conf.method == 'PATCH')", "service": "HttpBackendB", "input": { - "content": "=$.conf.payload" + "content": "=$.conf.content" }, "halt": "($.HttpBackendB.error != nil) && !error.isneterror($.HttpBackendB.error)" }, diff --git a/internal/pattern/assets.go b/internal/pattern/assets.go index ed910aa..4f709a8 100644 --- a/internal/pattern/assets.go +++ b/internal/pattern/assets.go @@ -69,7 +69,7 @@ func (fi bindataFileInfo) Sys() interface{} { return nil } -var _defaulthttppatternJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xe4\x57\x4d\x73\xdb\x36\x10\xbd\xeb\x57\x6c\x38\x9e\x28\x9e\x71\x68\xf7\xe3\xa4\x19\x1d\x2c\x37\xd3\x34\xad\xa7\x99\x44\x69\x0e\x9d\x1e\x20\x72\x25\xc2\x02\x01\x16\x58\xc8\x55\x13\xff\xf7\x0e\x40\x52\x06\x3f\x44\xc9\x76\xeb\x4b\x2f\xb6\x08\x3c\x2c\xde\xbe\x5d\xec\x02\x5f\x46\x00\x91\x64\x39\x46\x13\x88\x7e\xc0\x25\xb3\x82\xde\x12\x15\xef\x19\x11\x6a\x19\x9d\xb9\x79\x43\x58\x98\x68\x02\xbf\x8f\x00\x00\xbe\xf8\xbf\x00\x11\x5f\xba\x45\x27\x71\xa2\xe4\x32\xb6\x06\x3f\x30\xc2\x5f\x78\xce\x09\x35\x4c\xa7\x40\xda\xa2\x5f\xef\xc1\x06\xf5\x86\x27\x7e\x9b\x00\x77\x3f\xcf\x65\x61\x29\x9a\xec\xac\x03\x44\xa4\xd6\x28\xdd\x82\x95\x50\x0b\x26\xa2\x6a\xe6\xce\xff\xbf\x3b\x1b\x26\xf3\xee\xf3\x7c\x90\xc4\xbb\xcf\xf3\xdf\x98\xe0\x29\x23\x75\x24\x8b\xe9\x49\x5c\xb0\xad\x50\x2c\x8d\x33\x64\x29\x6a\x13\x5f\x5a\xca\x94\xe6\x7f\x33\xe2\x4a\xee\xac\xb8\x8d\xf8\x4a\x72\xb9\xba\x46\xca\x54\x5a\x2d\xf6\xcc\x6e\x6e\xe9\x63\x63\x2e\x58\xb4\xc6\x6d\x0b\xfa\x33\x6e\x43\x00\xb3\x6d\x5b\x97\xb6\x61\x81\x1b\xd3\x02\xfc\x64\x4c\x83\x97\x5d\xb4\xd9\xd8\xc5\xc3\x84\xbd\xe2\x3a\xb1\x9c\x66\x1a\xd9\xfa\x40\xa0\x9b\xd0\x68\xc0\xfc\xab\x4e\xe0\x96\x4c\x18\x84\xaf\x5f\xe1\x24\x0e\x43\x15\x2b\x4b\x85\x25\x13\x6f\xdc\x48\xbd\xfb\x29\xbc\x7c\x09\x95\x89\xdc\xeb\xea\x66\xc6\x3f\xbe\x99\x8f\x23\xe8\x63\xe6\x52\x7c\xc6\x92\x35\xca\xf4\xf2\x9e\x7a\xc6\x04\x55\x6c\x42\x40\x8c\x5a\x2b\x0d\x2f\xa6\x20\xb9\xf0\x5b\xbd\xf0\x23\x31\x37\x12\xc9\xff\xec\x5d\x71\xfa\x5f\x7b\xfc\xaa\xeb\xf2\xfb\x4f\xf3\x71\x69\xa3\x33\xf3\xeb\xc7\xbd\x53\x97\xf3\xab\xb7\xe3\xd3\xde\x18\x06\x6e\xcd\x06\xcf\x49\xa2\x24\xa1\xa4\x30\xbd\xaa\xe3\xb2\xcb\xaf\x03\x42\xcf\x1e\x2c\xf4\xec\x08\xa1\x0f\x65\x6e\x99\x3a\x81\xd1\x06\x8b\x63\xf2\x7a\x48\x15\x55\xa0\x2e\xab\xc3\xc4\x49\x64\x25\xd5\x07\xe1\x69\xe7\x6d\x1f\xeb\xe9\xbf\xcf\x5a\xa3\x41\x6a\x71\x1e\x01\xfc\xe1\x5b\x83\x46\x53\x28\x69\x70\xa0\x3d\x04\xe5\x7e\x97\xcb\xc2\x7d\x7f\x40\x96\x64\x98\x76\x4b\x88\x77\x25\x9a\xf8\xd1\xdd\x60\xb9\xb4\x9d\x73\xa9\x73\xed\xfb\x8b\xef\x82\x1a\x97\x32\x62\x0d\x98\xef\x60\x8c\xac\xa9\x9b\x0f\x78\x3a\xf0\xe6\xaf\x04\x31\xc5\x14\x5e\xc3\x3c\x43\xa8\xa4\x82\xad\xb2\x90\xb1\x0d\x82\xc6\x3f\x2d\x1a\xc2\x14\xb8\x01\xb5\x41\x0d\x94\x21\x30\x21\xd4\x2d\xa6\xe0\x5d\x88\xa3\xdd\x2e\x77\x8f\x6d\x4f\x65\x28\x87\x8f\xbc\xaf\x0d\x4f\x11\xe8\x9b\x03\x02\x79\x8b\xd7\x68\x0c\x5b\x61\x75\x84\x7b\x19\x35\x70\x67\xa1\x85\x4d\x89\xe5\x4a\x1e\x61\xa6\x0b\x7e\xa4\x8e\x43\xa7\xa3\x39\xb7\xdb\x9b\x34\x2f\x8a\xe7\x49\xbb\xda\x62\x94\x94\x54\x60\x51\xf1\xac\x38\x3c\xd4\xeb\x46\x8f\xa9\xfd\x71\x1b\xbb\x6a\x35\x1e\x77\x5d\xf1\x79\x73\x8c\x2f\xdf\x5e\x5c\x74\x7d\x71\xe1\xdb\xbb\xe5\x71\x55\xac\x51\xac\x9f\x9d\xf1\xec\x01\x8c\x1f\x43\x60\x4f\x51\xac\x2a\x49\x4f\x4d\xac\x6f\xda\xbd\x57\xe0\x14\x4d\xa2\x79\x51\xd7\x5d\x5f\xa9\x44\x1b\xa4\xd1\x2b\xbb\xe2\x94\xd9\x45\x9c\xa8\xfc\xbc\xd0\xea\x06\x13\x7a\xbd\x14\x6a\xa5\xce\x73\x9e\x68\xb5\x62\x84\xb7\x6c\x7b\xce\x12\xe2\x1b\x4e\xdb\x73\xcd\x08\x3b\xa6\x0c\x12\x71\xb9\x32\x4d\xef\x3c\x2c\xec\xe2\xba\xe6\x3a\xac\x5f\xed\x5a\xff\xc5\xba\xe5\x5b\x85\x40\x30\x2a\x47\xf0\x57\x6c\xf3\x54\x1f\x6f\x6e\xa9\xff\x1e\x50\x33\xdb\xd7\x00\x5b\xdc\xae\x5a\x67\xb5\x6e\xa1\x4f\xa4\x57\x95\x80\x45\x7b\xf7\xfe\x28\xe4\x65\x8e\xed\x82\xe0\xbf\x83\x7c\xa7\x4c\xa3\xc9\x94\x68\x3c\x08\xee\x07\x43\x24\xcf\x51\xd9\x46\x44\xeb\xa1\x00\x55\xa0\xe6\xcd\x97\x4a\x35\x72\x54\xcc\xfb\xaf\xd3\x2d\x5d\xaf\xd9\x1a\x81\x49\xc8\x88\x0a\x48\x98\x10\x40\xca\x35\x5b\x0d\x8b\x72\xe9\xf1\x0a\xbb\xbb\xa6\xe6\x8b\x20\xbf\xd1\xd0\x41\x49\x3b\x8f\xb1\xbc\xf3\x04\xb3\x9a\x87\x80\x8a\xd8\x27\x7d\xe0\xf1\xd9\xa3\xc3\xec\x7f\xa1\x83\x2b\x79\xa3\xbb\xd1\x3f\x01\x00\x00\xff\xff\x98\x3d\x01\x6a\x46\x10\x00\x00") +var _defaulthttppatternJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xe4\x57\x4d\x73\xdb\x36\x10\xbd\xeb\x57\x6c\x38\x9e\x28\x9e\x71\x68\xf7\xe3\xa4\x19\x1d\x2c\x37\xd3\x34\xad\xa7\x99\x44\x69\x0e\x9d\x1e\x20\x72\x25\xc2\x02\x01\x16\x58\xc8\x55\x13\xff\xf7\x0e\x40\x52\x06\x3f\x44\xc9\x76\xeb\x4b\x2f\xb6\x08\x3c\x2c\xde\xbe\x5d\xec\x02\x5f\x46\x00\x91\x64\x39\x46\x13\x88\x7e\xc0\x25\xb3\x82\xde\x12\x15\xef\x19\x11\x6a\x19\x9d\xb9\x79\x43\x58\x98\x68\x02\xbf\x8f\x00\x00\xbe\xf8\xbf\x00\x11\x5f\xba\x45\x27\x71\xa2\xe4\x32\xb6\x06\x3f\x30\xc2\x5f\x78\xce\x09\x35\x4c\xa7\x40\xda\xa2\x5f\xef\xc1\x06\xf5\x86\x27\x7e\x9b\x00\x77\x3f\xcf\x65\x61\x29\x9a\xec\xac\x03\x44\xa4\xd6\x28\xdd\x82\x95\x50\x0b\x26\xa2\x6a\xe6\xce\xff\xbf\x3b\x1b\x26\xf3\xee\xf3\x7c\x90\xc4\xbb\xcf\xf3\xdf\x98\xe0\x29\x23\x75\x24\x8b\xe9\x49\x5c\xb0\xad\x50\x2c\x8d\x33\x64\x29\x6a\x13\x5f\x5a\xca\x94\xe6\x7f\x33\xe2\x4a\xee\xac\xb8\x8d\xf8\x4a\x72\xb9\xba\x46\xca\x54\x5a\x2d\xf6\xcc\x6e\x6e\xe9\x63\x63\x2e\x58\xb4\xc6\x6d\x0b\xfa\x33\x6e\x43\x00\xb3\x6d\x5b\x97\xb6\x61\x81\x1b\xd3\x02\xfc\x64\x4c\x83\x97\x5d\xb4\xd9\xd8\xc5\xc3\x84\xbd\xe2\x3a\xb1\x9c\x66\x1a\xd9\xfa\x40\xa0\x9b\xd0\x68\xc0\xfc\xab\x4e\xe0\x96\x4c\x18\x84\xaf\x5f\xe1\x24\x0e\x43\x15\x2b\x4b\x85\x25\x13\x6f\xdc\x48\xbd\xfb\x29\xbc\x7c\x09\x95\x89\xdc\xeb\xea\x66\xc6\x3f\xbe\x99\x8f\x23\xe8\x63\xe6\x52\x7c\xc6\x92\x35\xca\xf4\xf2\x9e\x7a\xc6\x04\x55\x6c\x42\x40\x8c\x5a\x2b\x0d\x2f\xa6\x20\xb9\xf0\x5b\xbd\xf0\x23\x31\x37\x12\xc9\xff\xec\x5d\x71\xfa\x5f\x7b\xfc\xaa\xeb\xf2\xfb\x4f\xf3\x71\x69\xa3\x33\xf3\xeb\xc7\xbd\x53\x97\xf3\xab\xb7\xe3\xd3\xde\x18\x06\x6e\xcd\x06\xcf\x49\xa2\x24\xa1\xa4\x30\xbd\xea\xa1\x3a\xbf\x0e\x08\x3d\x7b\xb0\xd0\xb3\x23\x84\x3e\x94\xb9\x65\xea\x04\x46\x1b\x2c\x8e\xc9\xeb\x21\x55\x54\x81\xba\xac\x0e\x13\x27\x91\x95\x54\x1f\x84\xa7\x9d\xb7\x7d\xac\xa7\xff\x3e\x6b\x8d\x06\xa9\xc5\x79\x04\xf0\x87\x6f\x0d\x1a\x4d\xa1\xa4\xc1\x81\xf6\x10\x94\xfb\x5d\x2e\x0b\xf7\xfd\x01\x59\x92\x61\xda\x2d\x21\xde\x95\x68\xe2\x47\x77\x83\xe5\xd2\x76\xce\xa5\xce\xb5\xef\x2f\xbe\x0b\x6a\x5c\xca\x88\x35\x60\xbe\x83\x31\xb2\xa6\x6e\x3e\xe0\xe9\xc0\x9b\xbf\x12\xc4\x14\x53\x78\x0d\xf3\x0c\xa1\x92\x0a\xb6\xca\x42\xc6\x36\x08\x1a\xff\xb4\x68\x08\x53\xe0\x06\xd4\x06\x35\x50\x86\xc0\x84\x50\xb7\x98\x82\x77\x21\x8e\x76\xbb\xdc\x3d\xb6\x3d\x95\xa1\x1c\x3e\xf2\xbe\x36\x3c\x45\xa0\x6f\x0e\x08\xe4\x2d\x5e\xa3\x31\x6c\x85\xd5\x11\xee\x65\xd4\xc0\x9d\x85\x16\x36\x25\x96\x2b\x79\x84\x99\x2e\xf8\x91\x3a\x0e\x9d\x8e\xe6\xdc\x6e\x6f\xd2\xbc\x28\x9e\x27\xed\x6a\x8b\x51\x52\x52\x81\x45\xc5\xb3\xe2\xf0\x50\xaf\x1b\x3d\xa6\xf6\xc7\x6d\xec\xaa\xd5\x78\xdc\x75\xc5\xe7\xcd\x31\xbe\x7c\x7b\x71\xd1\xf5\xc5\x85\x6f\xef\x96\xc7\x55\xb1\x46\xb1\x7e\x76\xc6\xb3\x07\x30\x7e\x0c\x81\x3d\x45\xb1\xaa\x24\x3d\x35\xb1\xbe\x69\xf7\x5e\x81\x53\x34\x89\xe6\x45\x5d\x77\x7d\xa5\x12\x6d\x90\x46\xaf\xec\x8a\x53\x66\x17\x71\xa2\xf2\xf3\x42\xab\x1b\x4c\xe8\xf5\x52\xa8\x95\x3a\xcf\x79\xa2\xd5\x8a\x11\xde\xb2\xed\x39\x4b\x88\x6f\x38\x6d\xcf\x35\x23\xec\x98\x32\x48\xc4\xe5\xca\x34\xbd\xf3\xb0\xb0\x8b\xeb\x9a\xeb\xb0\x7e\xb5\x6b\xfd\x17\xeb\x96\x6f\x15\x02\xc1\xa8\x1c\xc1\x5f\xb1\xcd\x53\x7d\xbc\xb9\xa5\xfe\x7b\x40\xcd\x6c\x5f\x03\x6c\x71\xbb\x6a\x9d\xd5\xba\x85\x3e\x91\x5e\x55\x02\x16\xed\xdd\xfb\xa3\x90\x97\x39\xb6\x0b\x82\xff\x0e\xf2\x9d\x32\x8d\x26\x53\xa2\xf1\x20\xb8\x1f\x0c\x91\x3c\x47\x65\x1b\x11\xad\x87\x02\x54\x81\x9a\x37\x5f\x2a\xd5\xc8\x51\x31\xef\xbf\x4e\xb7\x74\xbd\x66\x6b\x04\x26\x21\x23\x2a\x20\x61\x42\x00\x29\xd7\x6c\x35\x2c\xca\xa5\xc7\x2b\xec\x2e\x96\x9a\x2f\x82\xfc\x46\x43\x07\x25\xed\x3c\xc6\xf2\xce\x13\xcc\x6a\x1e\x02\x2a\x62\x9f\xf4\x81\xc7\x67\x8f\x0e\xb3\xff\x85\x0e\xae\xe4\x8d\xee\x46\xff\x04\x00\x00\xff\xff\xbd\xb3\xaf\xb0\x46\x10\x00\x00") func defaulthttppatternJsonBytes() ([]byte, error) { return bindataRead( @@ -84,7 +84,7 @@ func defaulthttppatternJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "DefaultHttpPattern.json", size: 4166, mode: os.FileMode(420), modTime: time.Unix(1549489516, 0)} + info := bindataFileInfo{name: "DefaultHttpPattern.json", size: 4166, mode: os.FileMode(420), modTime: time.Unix(1549493757, 0)} a := &asset{bytes: bytes, info: info} return a, nil } From b9237170ab78aa388f4a32b4938032d968b63135 Mon Sep 17 00:00:00 2001 From: Akshay Gadikar Date: Thu, 7 Feb 2019 13:03:36 -0800 Subject: [PATCH 3/7] fix --- internal/pattern/DefaultHttpPattern.json | 13 +++++++------ internal/pattern/assets.go | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/internal/pattern/DefaultHttpPattern.json b/internal/pattern/DefaultHttpPattern.json index 53dc549..be486e9 100644 --- a/internal/pattern/DefaultHttpPattern.json +++ b/internal/pattern/DefaultHttpPattern.json @@ -38,14 +38,14 @@ "halt": "($.HttpBackendB.error != nil) && !error.isneterror($.HttpBackendB.error)" }, { - "if": "$.conf.useCircuitBreaker == true && $.HttpBackend.error != nil", + "if": "$.conf.useCircuitBreaker == true && (($.HttpBackendA.error != nil && $.conf.method == 'GET')|| ($.HttpBackendB.error != nil && $.conf.method == 'PUT'))", "service": "CircuitBreaker", "input": { "operation": "counter" } }, { - "if": "$.conf.useCircuitBreaker == true && $.HttpBackend.error == nil", + "if": "$.conf.useCircuitBreaker == true && (($.HttpBackendA.error == nil && $.conf.method == 'GET')|| ($.HttpBackendB.error == nil && $.conf.method == 'PUT'))", "service": "CircuitBreaker", "input": { "operation": "reset" @@ -85,7 +85,7 @@ } }, { - "if": "$.HttpBackendA.outputs.data != ''", + "if": "($.conf.useJWT == false || $.JWTValidator.outputs.valid == true) && $.conf.method == 'GET'", "error": false, "output": { "code": 200, @@ -93,7 +93,7 @@ } }, { - "if": "$.HttpBackendB.outputs.data != ''", + "if": "($.conf.useJWT == false || $.JWTValidator.outputs.valid == true) && ($.conf.method == 'PUT' || $.conf.method == 'POST' || $.conf.method == 'PATCH')", "error": false, "output": { "code": 200, @@ -101,9 +101,10 @@ } }, { - "error": false, + "error": true, "output": { - "code": 200 + "code": 400, + "data": "Error" } } ], diff --git a/internal/pattern/assets.go b/internal/pattern/assets.go index 4f709a8..661fede 100644 --- a/internal/pattern/assets.go +++ b/internal/pattern/assets.go @@ -69,7 +69,7 @@ func (fi bindataFileInfo) Sys() interface{} { return nil } -var _defaulthttppatternJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xe4\x57\x4d\x73\xdb\x36\x10\xbd\xeb\x57\x6c\x38\x9e\x28\x9e\x71\x68\xf7\xe3\xa4\x19\x1d\x2c\x37\xd3\x34\xad\xa7\x99\x44\x69\x0e\x9d\x1e\x20\x72\x25\xc2\x02\x01\x16\x58\xc8\x55\x13\xff\xf7\x0e\x40\x52\x06\x3f\x44\xc9\x76\xeb\x4b\x2f\xb6\x08\x3c\x2c\xde\xbe\x5d\xec\x02\x5f\x46\x00\x91\x64\x39\x46\x13\x88\x7e\xc0\x25\xb3\x82\xde\x12\x15\xef\x19\x11\x6a\x19\x9d\xb9\x79\x43\x58\x98\x68\x02\xbf\x8f\x00\x00\xbe\xf8\xbf\x00\x11\x5f\xba\x45\x27\x71\xa2\xe4\x32\xb6\x06\x3f\x30\xc2\x5f\x78\xce\x09\x35\x4c\xa7\x40\xda\xa2\x5f\xef\xc1\x06\xf5\x86\x27\x7e\x9b\x00\x77\x3f\xcf\x65\x61\x29\x9a\xec\xac\x03\x44\xa4\xd6\x28\xdd\x82\x95\x50\x0b\x26\xa2\x6a\xe6\xce\xff\xbf\x3b\x1b\x26\xf3\xee\xf3\x7c\x90\xc4\xbb\xcf\xf3\xdf\x98\xe0\x29\x23\x75\x24\x8b\xe9\x49\x5c\xb0\xad\x50\x2c\x8d\x33\x64\x29\x6a\x13\x5f\x5a\xca\x94\xe6\x7f\x33\xe2\x4a\xee\xac\xb8\x8d\xf8\x4a\x72\xb9\xba\x46\xca\x54\x5a\x2d\xf6\xcc\x6e\x6e\xe9\x63\x63\x2e\x58\xb4\xc6\x6d\x0b\xfa\x33\x6e\x43\x00\xb3\x6d\x5b\x97\xb6\x61\x81\x1b\xd3\x02\xfc\x64\x4c\x83\x97\x5d\xb4\xd9\xd8\xc5\xc3\x84\xbd\xe2\x3a\xb1\x9c\x66\x1a\xd9\xfa\x40\xa0\x9b\xd0\x68\xc0\xfc\xab\x4e\xe0\x96\x4c\x18\x84\xaf\x5f\xe1\x24\x0e\x43\x15\x2b\x4b\x85\x25\x13\x6f\xdc\x48\xbd\xfb\x29\xbc\x7c\x09\x95\x89\xdc\xeb\xea\x66\xc6\x3f\xbe\x99\x8f\x23\xe8\x63\xe6\x52\x7c\xc6\x92\x35\xca\xf4\xf2\x9e\x7a\xc6\x04\x55\x6c\x42\x40\x8c\x5a\x2b\x0d\x2f\xa6\x20\xb9\xf0\x5b\xbd\xf0\x23\x31\x37\x12\xc9\xff\xec\x5d\x71\xfa\x5f\x7b\xfc\xaa\xeb\xf2\xfb\x4f\xf3\x71\x69\xa3\x33\xf3\xeb\xc7\xbd\x53\x97\xf3\xab\xb7\xe3\xd3\xde\x18\x06\x6e\xcd\x06\xcf\x49\xa2\x24\xa1\xa4\x30\xbd\xea\xa1\x3a\xbf\x0e\x08\x3d\x7b\xb0\xd0\xb3\x23\x84\x3e\x94\xb9\x65\xea\x04\x46\x1b\x2c\x8e\xc9\xeb\x21\x55\x54\x81\xba\xac\x0e\x13\x27\x91\x95\x54\x1f\x84\xa7\x9d\xb7\x7d\xac\xa7\xff\x3e\x6b\x8d\x06\xa9\xc5\x79\x04\xf0\x87\x6f\x0d\x1a\x4d\xa1\xa4\xc1\x81\xf6\x10\x94\xfb\x5d\x2e\x0b\xf7\xfd\x01\x59\x92\x61\xda\x2d\x21\xde\x95\x68\xe2\x47\x77\x83\xe5\xd2\x76\xce\xa5\xce\xb5\xef\x2f\xbe\x0b\x6a\x5c\xca\x88\x35\x60\xbe\x83\x31\xb2\xa6\x6e\x3e\xe0\xe9\xc0\x9b\xbf\x12\xc4\x14\x53\x78\x0d\xf3\x0c\xa1\x92\x0a\xb6\xca\x42\xc6\x36\x08\x1a\xff\xb4\x68\x08\x53\xe0\x06\xd4\x06\x35\x50\x86\xc0\x84\x50\xb7\x98\x82\x77\x21\x8e\x76\xbb\xdc\x3d\xb6\x3d\x95\xa1\x1c\x3e\xf2\xbe\x36\x3c\x45\xa0\x6f\x0e\x08\xe4\x2d\x5e\xa3\x31\x6c\x85\xd5\x11\xee\x65\xd4\xc0\x9d\x85\x16\x36\x25\x96\x2b\x79\x84\x99\x2e\xf8\x91\x3a\x0e\x9d\x8e\xe6\xdc\x6e\x6f\xd2\xbc\x28\x9e\x27\xed\x6a\x8b\x51\x52\x52\x81\x45\xc5\xb3\xe2\xf0\x50\xaf\x1b\x3d\xa6\xf6\xc7\x6d\xec\xaa\xd5\x78\xdc\x75\xc5\xe7\xcd\x31\xbe\x7c\x7b\x71\xd1\xf5\xc5\x85\x6f\xef\x96\xc7\x55\xb1\x46\xb1\x7e\x76\xc6\xb3\x07\x30\x7e\x0c\x81\x3d\x45\xb1\xaa\x24\x3d\x35\xb1\xbe\x69\xf7\x5e\x81\x53\x34\x89\xe6\x45\x5d\x77\x7d\xa5\x12\x6d\x90\x46\xaf\xec\x8a\x53\x66\x17\x71\xa2\xf2\xf3\x42\xab\x1b\x4c\xe8\xf5\x52\xa8\x95\x3a\xcf\x79\xa2\xd5\x8a\x11\xde\xb2\xed\x39\x4b\x88\x6f\x38\x6d\xcf\x35\x23\xec\x98\x32\x48\xc4\xe5\xca\x34\xbd\xf3\xb0\xb0\x8b\xeb\x9a\xeb\xb0\x7e\xb5\x6b\xfd\x17\xeb\x96\x6f\x15\x02\xc1\xa8\x1c\xc1\x5f\xb1\xcd\x53\x7d\xbc\xb9\xa5\xfe\x7b\x40\xcd\x6c\x5f\x03\x6c\x71\xbb\x6a\x9d\xd5\xba\x85\x3e\x91\x5e\x55\x02\x16\xed\xdd\xfb\xa3\x90\x97\x39\xb6\x0b\x82\xff\x0e\xf2\x9d\x32\x8d\x26\x53\xa2\xf1\x20\xb8\x1f\x0c\x91\x3c\x47\x65\x1b\x11\xad\x87\x02\x54\x81\x9a\x37\x5f\x2a\xd5\xc8\x51\x31\xef\xbf\x4e\xb7\x74\xbd\x66\x6b\x04\x26\x21\x23\x2a\x20\x61\x42\x00\x29\xd7\x6c\x35\x2c\xca\xa5\xc7\x2b\xec\x2e\x96\x9a\x2f\x82\xfc\x46\x43\x07\x25\xed\x3c\xc6\xf2\xce\x13\xcc\x6a\x1e\x02\x2a\x62\x9f\xf4\x81\xc7\x67\x8f\x0e\xb3\xff\x85\x0e\xae\xe4\x8d\xee\x46\xff\x04\x00\x00\xff\xff\xbd\xb3\xaf\xb0\x46\x10\x00\x00") +var _defaulthttppatternJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xe4\x57\xcd\x72\xdb\x36\x10\xbe\xeb\x29\x36\x1c\x4f\x1c\xcd\x38\xb4\xfb\x73\xd2\x8c\x0e\x96\xeb\x69\x9a\xd6\xd3\x4c\xa2\x34\x87\x4e\x0f\x10\xb9\x12\x61\x81\x00\x0b\x2c\xe4\xaa\xb1\xdf\xbd\x43\x90\x94\xc1\x1f\x51\x92\x35\xca\xa5\x17\x5b\x04\x76\x17\xdf\x7e\xbb\xd8\xc5\x7e\x1d\x00\x04\x92\xa5\x18\x8c\x20\xf8\x09\xe7\xcc\x0a\x7a\x47\x94\x7d\x60\x44\xa8\x65\x70\x91\xef\x1b\xc2\xcc\x04\x23\xf8\x73\x00\x00\xf0\xd5\xfd\x05\x08\xf8\x3c\x57\x3a\x0b\x23\x25\xe7\xa1\x35\xf8\x91\x11\xfe\xc6\x53\x4e\xa8\x61\x3c\x06\xd2\x16\x9d\xbe\x13\x36\xa8\x57\x3c\x72\xc7\x78\x72\xcf\xfb\x5c\x66\x96\x82\xd1\xc6\x3a\x40\x40\x6a\x89\x32\x57\x58\x08\x35\x63\x22\x28\x77\x9e\xdc\xff\xa7\x8b\x7e\x30\xef\xbf\x4c\x7b\x41\xbc\xff\x32\xfd\x83\x09\x1e\x33\x52\x7b\xa2\x18\x9f\x85\x19\x5b\x0b\xc5\xe2\x30\x41\x16\xa3\x36\xe1\xb5\xa5\x44\x69\xfe\x2f\x23\xae\xe4\xc6\x4a\x7e\x10\x5f\x48\x2e\x17\x77\x48\x89\x8a\x4b\x65\x87\xec\xfe\x81\x3e\xd5\xf6\x3c\xa5\x25\xae\x1b\xa2\xbf\xe2\xda\x17\x60\xb6\x69\xeb\xda\xd6\x2c\x70\x63\x1a\x02\xbf\x18\x53\xc3\x65\x67\x4d\x34\x76\x76\x18\xb1\x37\x5c\x47\x96\xd3\x44\x23\x5b\xee\x08\x74\x5d\x34\xe8\x31\xff\xa6\x15\xb8\x39\x13\x06\xe1\xf1\x11\xce\x42\x3f\x54\xa1\xb2\x94\x59\x32\xe1\x2a\x5f\xa9\x4e\x1f\xc2\xeb\xd7\x50\x9a\x48\x1d\xaf\xf9\xce\xf9\xcf\xb7\xd3\xf3\x00\xba\x90\xe5\x29\x3e\x61\xd1\x12\x65\x7c\xfd\x0c\x3d\x61\x82\x4a\x34\xbe\x40\x88\x5a\x2b\x0d\xaf\xc6\x20\xb9\x70\x47\xbd\x72\x2b\x21\x37\x12\xc9\xfd\xec\xd4\x18\x9e\xda\xe3\x37\x6d\x97\x3f\x7c\x9e\x9e\x17\x36\x5a\x3b\xbf\x7f\xda\xba\x75\x3d\xbd\x79\x77\x3e\xec\x8c\xa1\xe7\xd6\xa4\xf7\x9e\x44\x4a\x12\x4a\xf2\xd3\xab\x5a\xaa\xf2\x6b\x07\xd1\x93\x83\x89\x9e\xec\x41\xf4\xae\xcc\x75\x44\xf6\x45\x7c\x7b\x6e\x0d\x1f\x1f\xa1\xcf\x85\x6e\xcd\x3c\x44\xc3\x6e\xb2\x1b\x17\xa6\x8f\x6e\x95\xa1\x2e\xca\xce\x28\xe7\xde\x4a\xaa\x6e\xd8\x71\x17\xb9\x87\x8e\xf1\x8b\xe9\xe8\xd3\x3c\x01\x1d\x1a\x0d\x52\x83\x8c\x01\xc0\x5f\xae\x99\x69\x34\x99\x92\x06\x7b\x1a\x9a\xd7\xa0\x36\xb7\x4f\xe4\xdf\x1f\x91\x45\x09\xc6\xed\xa2\xe7\xdc\x0c\x46\x6e\x75\xb3\x58\xa8\x36\x6f\x49\x9c\xbb\xf6\xe3\xd5\x0f\x5e\x55\x8e\x19\xb1\x9a\x98\xeb\xb9\x8c\xac\xa9\xda\x25\x38\x38\x70\xfb\x4f\x84\x18\x63\x0c\x6f\x61\x9a\x20\x94\x54\xc1\x5a\x59\x48\xd8\x0a\x41\xe3\xdf\x16\x0d\x61\x0c\xdc\x80\x5a\xa1\x06\x4a\x10\x98\x10\xea\x01\x63\x70\x2e\x84\xc1\xe6\x94\xa7\x97\x36\xd4\x22\x90\xfd\x45\xca\x55\xb3\x63\x08\xfa\x6e\x07\x41\xce\xe2\x1d\x1a\xc3\x16\x58\x16\x9d\x4e\x44\x35\xb9\x0b\xdf\xc2\xaa\x90\xe5\x4a\xee\x61\xa6\x2d\xfc\x42\x1e\xb7\x5f\xbb\xb3\xb0\xbe\xb7\x39\x9b\x34\xcf\xb2\x6f\x93\x76\x95\xc5\x20\x2a\xa0\xc0\xac\xc4\x59\x62\x38\xcc\xeb\x13\xb6\xf5\x16\x07\xce\xf2\x3e\x24\x7c\x7f\x75\xd5\x26\x21\x8f\x7b\xad\xe4\x55\x80\xdc\xfe\x37\x72\xf5\x64\xfd\xfc\x24\x1c\x4d\x0e\xe0\xe8\xf0\x44\xed\x3a\xff\xd6\x59\xd9\x52\xd7\xcb\x62\xd8\x51\xd6\xab\xf1\xa6\x73\xee\x88\xd1\x44\x9a\x67\x55\xeb\x70\xc5\x56\x34\x85\x34\xba\x18\x2f\x38\x25\x76\x16\x46\x2a\xbd\xcc\xb4\xba\xc7\x88\xde\xce\x85\x5a\xa8\xcb\x94\x47\x5a\x2d\x18\xe1\x03\x5b\x5f\xb2\x88\xf8\x8a\xd3\xfa\x52\x33\xc2\x96\x29\x83\x44\x5c\x2e\x4c\xdd\x6d\x27\xe6\x3f\x9d\x74\x85\xb5\x9f\xd7\xca\xb5\xee\x69\xa6\xe1\x5b\x29\x81\x60\x54\x8a\xe0\xe6\x1a\x73\xac\x8f\xf7\x0f\xd4\xfd\xf8\xaa\x90\x6d\xeb\xe1\x0d\x6c\x37\x8d\x72\x53\xbd\x02\x8e\x84\x57\x56\xb1\x59\xf3\xf4\xee\x28\xa4\x45\xf2\x6d\x82\xe0\xbe\xbd\x3c\xa4\x44\xa3\x49\x94\xa8\x4d\x61\xcf\x8b\xbe\x24\x4f\x51\xd9\x5a\x44\xab\x25\x4f\x2a\x43\xcd\xeb\xe3\x61\xb9\xb2\x57\xcc\xbb\x67\x98\x06\xaf\x77\x6c\x89\xc0\x24\x24\x44\x19\x44\x4c\x08\x20\x95\xbf\x17\x34\xcc\x0a\xd5\xfd\x19\xce\x5f\xf3\x9a\xcf\xbc\xfc\x46\x43\x3b\x29\x6d\x4d\xc0\x69\x6b\xee\xb5\x9a\xfb\x02\x25\xb0\xcf\x7a\xc7\xc4\xdf\xc1\xc3\xe4\x7f\xc1\x43\x5e\xf2\x06\x4f\x83\xff\x02\x00\x00\xff\xff\x2b\xb5\xd3\x95\xbb\x11\x00\x00") func defaulthttppatternJsonBytes() ([]byte, error) { return bindataRead( @@ -84,7 +84,7 @@ func defaulthttppatternJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "DefaultHttpPattern.json", size: 4166, mode: os.FileMode(420), modTime: time.Unix(1549493757, 0)} + info := bindataFileInfo{name: "DefaultHttpPattern.json", size: 4539, mode: os.FileMode(420), modTime: time.Unix(1549570330, 0)} a := &asset{bytes: bytes, info: info} return a, nil } From 134c851138eaed4290376a8c8593d2e4bd3cd7e2 Mon Sep 17 00:00:00 2001 From: Akshay Gadikar Date: Thu, 7 Feb 2019 13:29:05 -0800 Subject: [PATCH 4/7] fix - 1 --- internal/pattern/DefaultHttpPattern.json | 4 ++-- internal/pattern/assets.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/pattern/DefaultHttpPattern.json b/internal/pattern/DefaultHttpPattern.json index be486e9..1928a53 100644 --- a/internal/pattern/DefaultHttpPattern.json +++ b/internal/pattern/DefaultHttpPattern.json @@ -38,14 +38,14 @@ "halt": "($.HttpBackendB.error != nil) && !error.isneterror($.HttpBackendB.error)" }, { - "if": "$.conf.useCircuitBreaker == true && (($.HttpBackendA.error != nil && $.conf.method == 'GET')|| ($.HttpBackendB.error != nil && $.conf.method == 'PUT'))", + "if": "$.conf.useCircuitBreaker == true && (($.HttpBackendA.error != nil && $.conf.method == 'GET')|| ($.HttpBackendB.error != nil && ($.conf.method == 'PUT' || $.conf.method == 'POST' || $.conf.method == 'PATCH')))", "service": "CircuitBreaker", "input": { "operation": "counter" } }, { - "if": "$.conf.useCircuitBreaker == true && (($.HttpBackendA.error == nil && $.conf.method == 'GET')|| ($.HttpBackendB.error == nil && $.conf.method == 'PUT'))", + "if": "$.conf.useCircuitBreaker == true && (($.HttpBackendA.error == nil && $.conf.method == 'GET')|| ($.HttpBackendB.error == nil && ($.conf.method == 'PUT' || $.conf.method == 'POST' || $.conf.method == 'PATCH')))", "service": "CircuitBreaker", "input": { "operation": "reset" diff --git a/internal/pattern/assets.go b/internal/pattern/assets.go index 661fede..2b2333f 100644 --- a/internal/pattern/assets.go +++ b/internal/pattern/assets.go @@ -69,7 +69,7 @@ func (fi bindataFileInfo) Sys() interface{} { return nil } -var _defaulthttppatternJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xe4\x57\xcd\x72\xdb\x36\x10\xbe\xeb\x29\x36\x1c\x4f\x1c\xcd\x38\xb4\xfb\x73\xd2\x8c\x0e\x96\xeb\x69\x9a\xd6\xd3\x4c\xa2\x34\x87\x4e\x0f\x10\xb9\x12\x61\x81\x00\x0b\x2c\xe4\xaa\xb1\xdf\xbd\x43\x90\x94\xc1\x1f\x51\x92\x35\xca\xa5\x17\x5b\x04\x76\x17\xdf\x7e\xbb\xd8\xc5\x7e\x1d\x00\x04\x92\xa5\x18\x8c\x20\xf8\x09\xe7\xcc\x0a\x7a\x47\x94\x7d\x60\x44\xa8\x65\x70\x91\xef\x1b\xc2\xcc\x04\x23\xf8\x73\x00\x00\xf0\xd5\xfd\x05\x08\xf8\x3c\x57\x3a\x0b\x23\x25\xe7\xa1\x35\xf8\x91\x11\xfe\xc6\x53\x4e\xa8\x61\x3c\x06\xd2\x16\x9d\xbe\x13\x36\xa8\x57\x3c\x72\xc7\x78\x72\xcf\xfb\x5c\x66\x96\x82\xd1\xc6\x3a\x40\x40\x6a\x89\x32\x57\x58\x08\x35\x63\x22\x28\x77\x9e\xdc\xff\xa7\x8b\x7e\x30\xef\xbf\x4c\x7b\x41\xbc\xff\x32\xfd\x83\x09\x1e\x33\x52\x7b\xa2\x18\x9f\x85\x19\x5b\x0b\xc5\xe2\x30\x41\x16\xa3\x36\xe1\xb5\xa5\x44\x69\xfe\x2f\x23\xae\xe4\xc6\x4a\x7e\x10\x5f\x48\x2e\x17\x77\x48\x89\x8a\x4b\x65\x87\xec\xfe\x81\x3e\xd5\xf6\x3c\xa5\x25\xae\x1b\xa2\xbf\xe2\xda\x17\x60\xb6\x69\xeb\xda\xd6\x2c\x70\x63\x1a\x02\xbf\x18\x53\xc3\x65\x67\x4d\x34\x76\x76\x18\xb1\x37\x5c\x47\x96\xd3\x44\x23\x5b\xee\x08\x74\x5d\x34\xe8\x31\xff\xa6\x15\xb8\x39\x13\x06\xe1\xf1\x11\xce\x42\x3f\x54\xa1\xb2\x94\x59\x32\xe1\x2a\x5f\xa9\x4e\x1f\xc2\xeb\xd7\x50\x9a\x48\x1d\xaf\xf9\xce\xf9\xcf\xb7\xd3\xf3\x00\xba\x90\xe5\x29\x3e\x61\xd1\x12\x65\x7c\xfd\x0c\x3d\x61\x82\x4a\x34\xbe\x40\x88\x5a\x2b\x0d\xaf\xc6\x20\xb9\x70\x47\xbd\x72\x2b\x21\x37\x12\xc9\xfd\xec\xd4\x18\x9e\xda\xe3\x37\x6d\x97\x3f\x7c\x9e\x9e\x17\x36\x5a\x3b\xbf\x7f\xda\xba\x75\x3d\xbd\x79\x77\x3e\xec\x8c\xa1\xe7\xd6\xa4\xf7\x9e\x44\x4a\x12\x4a\xf2\xd3\xab\x5a\xaa\xf2\x6b\x07\xd1\x93\x83\x89\x9e\xec\x41\xf4\xae\xcc\x75\x44\xf6\x45\x7c\x7b\x6e\x0d\x1f\x1f\xa1\xcf\x85\x6e\xcd\x3c\x44\xc3\x6e\xb2\x1b\x17\xa6\x8f\x6e\x95\xa1\x2e\xca\xce\x28\xe7\xde\x4a\xaa\x6e\xd8\x71\x17\xb9\x87\x8e\xf1\x8b\xe9\xe8\xd3\x3c\x01\x1d\x1a\x0d\x52\x83\x8c\x01\xc0\x5f\xae\x99\x69\x34\x99\x92\x06\x7b\x1a\x9a\xd7\xa0\x36\xb7\x4f\xe4\xdf\x1f\x91\x45\x09\xc6\xed\xa2\xe7\xdc\x0c\x46\x6e\x75\xb3\x58\xa8\x36\x6f\x49\x9c\xbb\xf6\xe3\xd5\x0f\x5e\x55\x8e\x19\xb1\x9a\x98\xeb\xb9\x8c\xac\xa9\xda\x25\x38\x38\x70\xfb\x4f\x84\x18\x63\x0c\x6f\x61\x9a\x20\x94\x54\xc1\x5a\x59\x48\xd8\x0a\x41\xe3\xdf\x16\x0d\x61\x0c\xdc\x80\x5a\xa1\x06\x4a\x10\x98\x10\xea\x01\x63\x70\x2e\x84\xc1\xe6\x94\xa7\x97\x36\xd4\x22\x90\xfd\x45\xca\x55\xb3\x63\x08\xfa\x6e\x07\x41\xce\xe2\x1d\x1a\xc3\x16\x58\x16\x9d\x4e\x44\x35\xb9\x0b\xdf\xc2\xaa\x90\xe5\x4a\xee\x61\xa6\x2d\xfc\x42\x1e\xb7\x5f\xbb\xb3\xb0\xbe\xb7\x39\x9b\x34\xcf\xb2\x6f\x93\x76\x95\xc5\x20\x2a\xa0\xc0\xac\xc4\x59\x62\x38\xcc\xeb\x13\xb6\xf5\x16\x07\xce\xf2\x3e\x24\x7c\x7f\x75\xd5\x26\x21\x8f\x7b\xad\xe4\x55\x80\xdc\xfe\x37\x72\xf5\x64\xfd\xfc\x24\x1c\x4d\x0e\xe0\xe8\xf0\x44\xed\x3a\xff\xd6\x59\xd9\x52\xd7\xcb\x62\xd8\x51\xd6\xab\xf1\xa6\x73\xee\x88\xd1\x44\x9a\x67\x55\xeb\x70\xc5\x56\x34\x85\x34\xba\x18\x2f\x38\x25\x76\x16\x46\x2a\xbd\xcc\xb4\xba\xc7\x88\xde\xce\x85\x5a\xa8\xcb\x94\x47\x5a\x2d\x18\xe1\x03\x5b\x5f\xb2\x88\xf8\x8a\xd3\xfa\x52\x33\xc2\x96\x29\x83\x44\x5c\x2e\x4c\xdd\x6d\x27\xe6\x3f\x9d\x74\x85\xb5\x9f\xd7\xca\xb5\xee\x69\xa6\xe1\x5b\x29\x81\x60\x54\x8a\xe0\xe6\x1a\x73\xac\x8f\xf7\x0f\xd4\xfd\xf8\xaa\x90\x6d\xeb\xe1\x0d\x6c\x37\x8d\x72\x53\xbd\x02\x8e\x84\x57\x56\xb1\x59\xf3\xf4\xee\x28\xa4\x45\xf2\x6d\x82\xe0\xbe\xbd\x3c\xa4\x44\xa3\x49\x94\xa8\x4d\x61\xcf\x8b\xbe\x24\x4f\x51\xd9\x5a\x44\xab\x25\x4f\x2a\x43\xcd\xeb\xe3\x61\xb9\xb2\x57\xcc\xbb\x67\x98\x06\xaf\x77\x6c\x89\xc0\x24\x24\x44\x19\x44\x4c\x08\x20\x95\xbf\x17\x34\xcc\x0a\xd5\xfd\x19\xce\x5f\xf3\x9a\xcf\xbc\xfc\x46\x43\x3b\x29\x6d\x4d\xc0\x69\x6b\xee\xb5\x9a\xfb\x02\x25\xb0\xcf\x7a\xc7\xc4\xdf\xc1\xc3\xe4\x7f\xc1\x43\x5e\xf2\x06\x4f\x83\xff\x02\x00\x00\xff\xff\x2b\xb5\xd3\x95\xbb\x11\x00\x00") +var _defaulthttppatternJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xe4\x58\x5f\x6f\xdb\x36\x10\x7f\xf7\xa7\xb8\x0a\x41\x53\x03\xa9\x92\xfd\x79\x32\xe0\x87\x38\x0b\xd6\x75\x0b\x56\xb4\xee\xfa\x30\xec\x81\x96\xce\x16\x63\x8a\xd4\xc8\xa3\x33\xaf\xc9\x77\x1f\x44\x49\x0e\xf5\xc7\xb2\x9d\xc0\x01\x86\xbe\x24\x11\xef\x78\xfc\xdd\xef\x8e\x77\xbc\x7c\x1d\x00\x04\x92\xa5\x18\x8c\x20\xf8\x09\xe7\xcc\x0a\x7a\x47\x94\x7d\x60\x44\xa8\x65\x70\x96\xcb\x0d\x61\x66\x82\x11\xfc\x39\x00\x00\xf8\xea\x7e\x02\x04\x7c\x9e\x6f\x3a\x09\x23\x25\xe7\xa1\x35\xf8\x91\x11\xfe\xc6\x53\x4e\xa8\x61\x3c\x06\xd2\x16\xdd\x7e\xa7\x6c\x50\xaf\x78\xe4\x8e\xf1\xf4\x1e\xe5\x5c\x66\x96\x82\xd1\xc6\x3a\x40\x40\x6a\x89\x32\xdf\xb0\x10\x6a\xc6\x44\x50\x4a\x1e\xdc\xef\x87\xb3\x7e\x30\xef\xbf\x4c\x7b\x41\xbc\xff\x32\xfd\x83\x09\x1e\x33\x52\x7b\xa2\x18\x9f\x84\x19\x5b\x0b\xc5\xe2\x30\x41\x16\xa3\x36\xe1\xa5\xa5\x44\x69\xfe\x2f\x23\xae\xe4\xc6\x4a\x7e\x10\x5f\x48\x2e\x17\x37\x48\x89\x8a\xcb\xcd\x0e\xd9\xed\x1d\x7d\xaa\xc9\xbc\x4d\x4b\x5c\x37\x54\x7f\xc5\xb5\xaf\xc0\x6c\xd3\xd6\xa5\xad\x59\xe0\xc6\x34\x14\x7e\x31\xa6\x86\xcb\xce\x9a\x68\xec\xec\x30\x62\xaf\xb8\x8e\x2c\xa7\x89\x46\xb6\xdc\x11\xe8\xba\x6a\xd0\x63\xfe\x4d\x2b\x70\x73\x26\x0c\xc2\xfd\x3d\x9c\x84\x7e\xa8\x42\x65\x29\xb3\x64\xc2\x55\xbe\x52\x9d\x3e\x84\xd7\xaf\xa1\x34\x91\x3a\x5e\x73\xc9\xe9\xcf\xd7\xd3\xd3\x00\xba\x90\xe5\x29\x3e\x61\xd1\x12\x65\x7c\xf9\x08\x3d\x61\x82\x4a\x34\xbe\x42\x88\x5a\x2b\x0d\xaf\xc6\x20\xb9\x70\x47\xbd\x72\x2b\x21\x37\x12\xc9\xfd\xd9\xb9\x63\x78\x6c\x8f\xdf\xb4\x5d\xfe\xf0\x79\x7a\x5a\xd8\x68\x49\x7e\xff\xb4\x55\x74\x39\xbd\x7a\x77\x3a\xec\x8c\xa1\xe7\xd6\xa4\xf7\x9e\x44\x4a\x12\x4a\xf2\xd3\xab\x5a\xaa\xf2\x6b\x07\xd1\x93\x83\x89\x9e\xec\x41\xf4\xae\xcc\x75\x44\xf6\x45\x7c\x7b\x6e\x0d\xef\xef\xa1\xcf\x85\x23\xc4\x68\xd8\x1d\xa5\xc6\x4d\xeb\x8b\x93\xca\x50\x17\xf5\x6a\x94\x07\xcd\x4a\xaa\xae\xe6\xf3\x2a\x40\x0f\x8f\xe3\x27\xf3\x38\xfe\x9f\xf0\xa8\xd1\x20\x35\x58\x1c\x00\xfc\xe5\xda\xa7\x46\x93\x29\x69\xb0\xa7\x85\x7a\x2d\x71\x73\xdf\x45\xfe\xfd\x11\x59\x94\x60\xdc\x2e\xb3\x8e\x9f\x60\xe4\x56\x37\x8b\xc5\xd6\xe6\xbd\x8c\x73\xd7\x7e\xbc\xf8\xc1\xeb\x03\x31\x23\x56\x53\x73\x5d\x9e\x91\x35\x55\x83\x06\x07\x07\xae\xff\x89\x10\x63\x8c\xe1\x2d\x4c\x13\x84\x92\x2a\x58\x2b\x0b\x09\x5b\x21\x68\xfc\xdb\xa2\x21\x8c\x81\x1b\x50\x2b\xd4\x40\x09\x02\x13\x42\xdd\x61\x0c\xce\x85\x30\xd8\x9c\xf2\xf0\xd4\x16\x5e\xe4\x4e\x7f\x59\x74\xf5\xf3\x39\x04\x7d\xb7\x83\x20\x67\xf1\x06\x8d\x61\x0b\x2c\xcb\x5c\x27\xa2\x9a\xde\x99\x6f\x61\x55\xe8\x72\x25\xf7\x30\xd3\x56\x7e\x22\x8f\xdb\xef\xeb\x49\x58\x97\x6d\xce\x26\xcd\xb3\xec\x65\xd2\xae\xb2\x18\x44\x05\x14\x98\x95\x38\x4b\x0c\x87\x79\x7d\xc4\x87\x44\x8b\x03\x67\x79\x1f\x12\xbe\xbf\xb8\x68\x93\x90\xc7\xbd\x56\x2b\x2b\x40\x4e\xfe\x42\xae\x1e\xed\x05\x71\x14\x8e\x26\x07\x70\x74\x78\xa2\x76\x9d\x7f\xed\xac\x6c\xa9\xeb\x65\x31\xec\x28\xeb\xd5\x40\xd5\x39\xe9\xc4\x68\x22\xcd\xb3\xaa\x75\xb8\x62\x2b\x9a\x4a\x1a\x5d\x8c\x17\x9c\x12\x3b\x0b\x23\x95\x9e\x67\x5a\xdd\x62\x44\x6f\xe7\x42\x2d\xd4\x79\xca\x23\xad\x16\x8c\xf0\x8e\xad\xcf\x59\x44\x7c\xc5\x69\x7d\xae\x19\x61\xcb\x94\x41\x22\x2e\x17\xa6\xee\xb6\x53\xf3\x1f\x6b\xba\xc2\xda\xcf\x6b\xe5\x5a\xf7\xfc\xd4\xf0\xad\xd4\x40\x30\x2a\x45\x70\x93\x94\x79\xae\x8f\xb7\x77\xd4\xfd\xdc\xab\x90\x6d\xeb\xe1\x0d\x6c\x57\x8d\x72\x53\xbd\x02\x9e\x09\xaf\xac\x62\xb3\xe6\xe9\xdd\x51\x48\x8b\xe4\xdb\x04\xc1\x7d\x7b\x79\x48\x89\x46\x93\x28\x51\x9b\xfb\x1e\x17\x7d\x4d\x9e\xa2\xb2\xb5\x88\x56\x4b\x9e\x56\x86\x9a\xd7\x07\xd2\x72\x65\xaf\x98\x77\x4f\x4d\x0d\x5e\x6f\xd8\x12\x81\x49\x48\x88\x32\x88\x98\x10\x40\x2a\x7f\x2f\x68\x98\x15\x5b\xf7\x67\x38\x9f\x1f\x34\x9f\x79\xf9\x8d\x86\x76\x52\xda\x9a\xb9\xd3\xd6\xa4\x6d\x35\xf7\x15\x4a\x60\x9f\xf5\x8e\xff\x31\x74\xf0\x30\xf9\x26\x78\xc8\x4b\xde\xe0\x61\xf0\x5f\x00\x00\x00\xff\xff\x30\x31\xfa\x4b\x2d\x12\x00\x00") func defaulthttppatternJsonBytes() ([]byte, error) { return bindataRead( @@ -84,7 +84,7 @@ func defaulthttppatternJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "DefaultHttpPattern.json", size: 4539, mode: os.FileMode(420), modTime: time.Unix(1549570330, 0)} + info := bindataFileInfo{name: "DefaultHttpPattern.json", size: 4653, mode: os.FileMode(420), modTime: time.Unix(1549574923, 0)} a := &asset{bytes: bytes, info: info} return a, nil } From fa766f407b3eb2d4734f6375de763844ac5f753c Mon Sep 17 00:00:00 2001 From: Akshay Gadikar Date: Mon, 11 Feb 2019 12:07:05 -0800 Subject: [PATCH 5/7] Basic integration tests and READme --- examples/api/default-http-pattern/README.md | 26 +++++ examples/api/default-http-pattern/main.go | 45 +------- examples/examples.go | 38 ++++++ examples/examples_test.go | 115 ++++++++++++++++++- examples/json/default-http-pattern/README.md | 27 +++++ 5 files changed, 208 insertions(+), 43 deletions(-) diff --git a/examples/api/default-http-pattern/README.md b/examples/api/default-http-pattern/README.md index e97a2c5..668e18e 100644 --- a/examples/api/default-http-pattern/README.md +++ b/examples/api/default-http-pattern/README.md @@ -1,6 +1,32 @@ # Gateway using Default Http Pattern This recipe is a gateway using the defult http pattern which uses JWT, Rate Limiter, and Circuit Breaker. +#Circuit Breaker Service: +| Name | Type | Description | +|:-----------|:--------|:--------------| +| mode | string | The tripping mode: 'a' for contiguous errors, 'b' for errors within a time period, 'c' for contiguous errors within a time period, and 'd' for a probabilistic smart circuit breaker mode. Defaults to mode 'a' | +| threshold | number | The number of errors required for tripping| +| period | number | Number of seconds in which errors have to occur for the circuit breaker to trip. Applies to modes 'b' and 'c'| +| timeout | number | Number of seconds that the circuit breaker will remain tripped. Applies to modes 'a', 'b', 'c'| + + +#Rate Limiter +| Name | Type | Description | +|:-----------|:--------|:--------------| +| limit | string | Limit can be specifed in the format of "limit-period". Valid periods are 'S', 'M' & 'H' to represent Second, Minute & Hour. Example: "10-S" represents 10 request/second | + + +#JWT +| Name | Type | Description | +|:-----------|:--------|:--------------| +| token | string | The raw token | +| key | string | The key used to sign the token | +| signingMethod | string | The signing method used (HMAC, ECDSA, RSA, RSAPSS) | +| issuer | string | The 'iss' standard claim to match against | +| subject | string | The 'sub' standard claim to match against | +| audience | string | The 'aud' standard claim to match against | + + ## Installation * Install [Go](https://golang.org/) diff --git a/examples/api/default-http-pattern/main.go b/examples/api/default-http-pattern/main.go index d727a43..3b40a34 100644 --- a/examples/api/default-http-pattern/main.go +++ b/examples/api/default-http-pattern/main.go @@ -7,11 +7,8 @@ import ( "io/ioutil" "net/http" - trigger "github.com/project-flogo/contrib/trigger/rest" - "github.com/project-flogo/core/api" "github.com/project-flogo/core/engine" - "github.com/project-flogo/microgateway" - + "github.com/project-flogo/microgateway/examples" _ "github.com/project-flogo/contrib/activity/rest" _ "github.com/project-flogo/microgateway/activity/circuitbreaker" _ "github.com/project-flogo/microgateway/activity/jwt" @@ -24,8 +21,7 @@ var ( const reply = `{ "id": 1, - "category": { - "id": 0, + "category": { "id": 0, "name": "string" }, "name": "sally", @@ -60,42 +56,7 @@ func main() { return } - - app := api.NewApp() - - trg := app.NewTrigger(&trigger.Trigger{}, &trigger.Settings{Port: 9096}) - handler, err := trg.NewHandler(&trigger.HandlerSettings{ - Method: "GET", - Path: "/endpoint", - }) - if err != nil { - panic(err) - } - - _, err = handler.NewAction(µgateway.Action{}, map[string]interface{}{ - "pattern": "DefaultHttpPattern", - "useRateLimiter": true, - "rateLimit": "1-S", - "useJWT": true, - "jwtSigningMethod": "HMAC", - "jwtKey": "qwertyuiopasdfghjklzxcvbnm789101", - "jwtAud": "www.mashling.io", - "jwtIss": "Mashling", - "jwtSub": "tempuser@mail.com", - "useCircuitBreaker": true, - "backendUrl": "http://localhost:1234/pets", - "mode": "a", - "threshold": 5, - "timeout": 60, - "period": 60, - "method": "GET", - "content": "", - }) - if err != nil { - panic(err) - } - - e, err := api.NewEngine(app) + e, err := examples.DefaultHttpPattern() if err != nil { panic(err) } diff --git a/examples/examples.go b/examples/examples.go index 80f715d..be3c425 100644 --- a/examples/examples.go +++ b/examples/examples.go @@ -123,3 +123,41 @@ func HandlerRoutingExample() (engine.Engine, error) { return api.NewEngine(app) } + +func DefaultHttpPattern ()(engine.Engine, error){ + app := api.NewApp() + + trg := app.NewTrigger(&trigger.Trigger{}, &trigger.Settings{Port: 9096}) + handler, err := trg.NewHandler(&trigger.HandlerSettings{ + Method: "GET", + Path: "/endpoint", + }) + if err != nil { + panic(err) + } + + _, err = handler.NewAction(µgateway.Action{}, map[string]interface{}{ + "pattern": "DefaultHttpPattern", + "useRateLimiter": true, + "rateLimit": "1-S", + "useJWT": true, + "jwtSigningMethod": "HMAC", + "jwtKey": "qwertyuiopasdfghjklzxcvbnm789101", + "jwtAud": "www.mashling.io", + "jwtIss": "Mashling", + "jwtSub": "tempuser@mail.com", + "useCircuitBreaker": true, + "backendUrl": "http://localhost:1234/pets", + "mode": "a", + "threshold": 5, + "timeout": 60, + "period": 60, + "method": "GET", + "content": "", + }) + if err != nil { + panic(err) + } + + return api.NewEngine(app) +} \ No newline at end of file diff --git a/examples/examples_test.go b/examples/examples_test.go index 0383561..d28fa35 100644 --- a/examples/examples_test.go +++ b/examples/examples_test.go @@ -7,11 +7,16 @@ import ( "net/http" "path/filepath" "testing" - + "time" + "context" "github.com/project-flogo/core/engine" "github.com/project-flogo/microgateway/api" test "github.com/project-flogo/microgateway/internal/testing" "github.com/stretchr/testify/assert" + _ "github.com/project-flogo/contrib/activity/rest" + _ "github.com/project-flogo/microgateway/activity/circuitbreaker" + _ "github.com/project-flogo/microgateway/activity/jwt" + _ "github.com/project-flogo/microgateway/activity/ratelimiter" ) // Response is a reply form the server @@ -19,6 +24,41 @@ type Response struct { Error string `json:"error"` } +type handler struct { + Slow bool +} + +func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + defer r.Body.Close() + _, err := ioutil.ReadAll(r.Body) + if err != nil { + panic(err) + } + + if h.Slow { + time.Sleep(10 * time.Second) + } + + w.Header().Set("Content-Type", "application/json") + _, err = w.Write([]byte(reply)) + if err != nil { + panic(err) + } +} + +const reply = `{ + "id": 1, + "category": { + "id": 0, + "name": "string" + }, + "name": "sally", + "photoUrls": ["string"], + "tags": [{ "id": 0,"name": "string" }], + "status":"available" +}` + + func testBasicGatewayApplication(t *testing.T, e engine.Engine) { defer api.ClearResources() test.Drain("9096") @@ -145,3 +185,76 @@ func TestHandlerRoutingIntegrationJSON(t *testing.T) { assert.Nil(t, err) testHandlerRoutingApplication(t, e) } + + +func testDefaultHttpPattern(t *testing.T, e engine.Engine) { + defer api.ClearResources() + test.Drain("1234") + testHandler := handler{} + s := &http.Server{ + Addr: ":1234", + Handler: &testHandler, + ReadTimeout: 10 * time.Second, + WriteTimeout: 10 * time.Second, + MaxHeaderBytes: 1 << 20, + } + go func() { + s.ListenAndServe() + }() + test.Pour("1234") + defer s.Shutdown(context.Background()) + + test.Drain("9096") + err := e.Start() + assert.Nil(t, err) + defer func() { + err := e.Stop() + assert.Nil(t, err) + }() + + test.Pour("9096") + + transport := &http.Transport{ + MaxIdleConns: 1, + } + defer transport.CloseIdleConnections() + client := &http.Client{ + Transport: transport, + } + request := func() string { + req, err := http.NewRequest(http.MethodGet, "http://localhost:9096/pets/1", nil) + assert.Nil(t, err) + response, err := client.Do(req) + assert.Nil(t, err) + body, err := ioutil.ReadAll(response.Body) + assert.Nil(t, err) + response.Body.Close() + return string(body) + } + + body := request() + assert.NotEqual(t, 0, string(body)) +} + +func TestDefaultHttpPatternAPI(t *testing.T) { + if testing.Short() { + t.Skip("skipping Basic Gateway API integration test in short mode") + } + + e, err := DefaultHttpPattern() + assert.Nil(t, err) + testDefaultHttpPattern(t, e) +} + +func TestDefaultHttpPatternJSON(t *testing.T) { + if testing.Short() { + t.Skip("skipping Basic Gateway JSON integration test in short mode") + } + data, err := ioutil.ReadFile(filepath.FromSlash("./json/default-http-pattern/flogo.json")) + assert.Nil(t, err) + cfg, err := engine.LoadAppConfig(string(data), false) + assert.Nil(t, err) + e, err := engine.New(cfg) + assert.Nil(t, err) + testDefaultHttpPattern(t, e) +} \ No newline at end of file diff --git a/examples/json/default-http-pattern/README.md b/examples/json/default-http-pattern/README.md index 7cd5b19..6021777 100644 --- a/examples/json/default-http-pattern/README.md +++ b/examples/json/default-http-pattern/README.md @@ -1,6 +1,33 @@ # Gateway using Default Http Pattern This recipe is a gateway using the defult http pattern which uses JWT, Rate Limiter, and Circuit Breaker. +#Circuit Breaker Service: +| Name | Type | Description | +|:-----------|:--------|:--------------| +| mode | string | The tripping mode: 'a' for contiguous errors, 'b' for errors within a time period, 'c' for contiguous errors within a time period, and 'd' for a probabilistic smart circuit breaker mode. Defaults to mode 'a' | +| threshold | number | The number of errors required for tripping| +| period | number | Number of seconds in which errors have to occur for the circuit breaker to trip. Applies to modes 'b' and 'c'| +| timeout | number | Number of seconds that the circuit breaker will remain tripped. Applies to modes 'a', 'b', 'c'| + + +#Rate Limiter +| Name | Type | Description | +|:-----------|:--------|:--------------| +| limit | string | Limit can be specifed in the format of "limit-period". Valid periods are 'S', 'M' & 'H' to represent Second, Minute & Hour. Example: "10-S" represents 10 request/second | + + +#JWT +| Name | Type | Description | +|:-----------|:--------|:--------------| +| token | string | The raw token | +| key | string | The key used to sign the token | +| signingMethod | string | The signing method used (HMAC, ECDSA, RSA, RSAPSS) | +| issuer | string | The 'iss' standard claim to match against | +| subject | string | The 'sub' standard claim to match against | +| audience | string | The 'aud' standard claim to match against | + + + ## Installation * Install [Go](https://golang.org/) * Install the flogo [cli](https://github.com/project-flogo/cli) From 009498ba0e426a06bbf136c139244e6de1d8706a Mon Sep 17 00:00:00 2001 From: Andrew Snodgrass Date: Tue, 12 Feb 2019 13:06:35 -0700 Subject: [PATCH 6/7] Updated pattern test --- action_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/action_test.go b/action_test.go index bba9d1c..93da50e 100644 --- a/action_test.go +++ b/action_test.go @@ -258,7 +258,12 @@ func TestMicrogatewayHttpPattern(t *testing.T) { "useJWT": false, "useCircuitBreaker": false, "backendUrl": "http://localhost:1234/", + "method": "GET", "rateLimit": "3-M", + "mode": "a", + "threshold": 5, + "timeout": 60, + "period": 60, }) assert.Nil(t, err) assert.NotNil(t, action) From 285a086f0ae406cbd8d349a82f22d2e9ea5b886a Mon Sep 17 00:00:00 2001 From: Andrew Snodgrass Date: Tue, 12 Feb 2019 13:22:30 -0700 Subject: [PATCH 7/7] Fixed code styling issues --- examples/api/default-http-pattern/main.go | 7 ++--- examples/examples.go | 17 ++++++------ examples/examples_test.go | 26 +++++++++---------- examples/json/default-http-pattern/flogo.json | 12 ++++----- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/examples/api/default-http-pattern/main.go b/examples/api/default-http-pattern/main.go index 3b40a34..3255f34 100644 --- a/examples/api/default-http-pattern/main.go +++ b/examples/api/default-http-pattern/main.go @@ -7,12 +7,12 @@ import ( "io/ioutil" "net/http" - "github.com/project-flogo/core/engine" - "github.com/project-flogo/microgateway/examples" _ "github.com/project-flogo/contrib/activity/rest" + "github.com/project-flogo/core/engine" _ "github.com/project-flogo/microgateway/activity/circuitbreaker" _ "github.com/project-flogo/microgateway/activity/jwt" _ "github.com/project-flogo/microgateway/activity/ratelimiter" + "github.com/project-flogo/microgateway/examples" ) var ( @@ -56,7 +56,8 @@ func main() { return } - e, err := examples.DefaultHttpPattern() + + e, err := examples.DefaultHTTPPattern() if err != nil { panic(err) } diff --git a/examples/examples.go b/examples/examples.go index be3c425..a2a8516 100644 --- a/examples/examples.go +++ b/examples/examples.go @@ -124,7 +124,8 @@ func HandlerRoutingExample() (engine.Engine, error) { return api.NewEngine(app) } -func DefaultHttpPattern ()(engine.Engine, error){ +// DefaultHTTPPattern returns an engine configured for the DefaultHttpPattern +func DefaultHTTPPattern() (engine.Engine, error) { app := api.NewApp() trg := app.NewTrigger(&trigger.Trigger{}, &trigger.Settings{Port: 9096}) @@ -148,16 +149,16 @@ func DefaultHttpPattern ()(engine.Engine, error){ "jwtSub": "tempuser@mail.com", "useCircuitBreaker": true, "backendUrl": "http://localhost:1234/pets", - "mode": "a", - "threshold": 5, - "timeout": 60, - "period": 60, - "method": "GET", - "content": "", + "mode": "a", + "threshold": 5, + "timeout": 60, + "period": 60, + "method": "GET", + "content": "", }) if err != nil { panic(err) } return api.NewEngine(app) -} \ No newline at end of file +} diff --git a/examples/examples_test.go b/examples/examples_test.go index d28fa35..e5a8143 100644 --- a/examples/examples_test.go +++ b/examples/examples_test.go @@ -1,6 +1,7 @@ package examples import ( + "context" "encoding/json" "fmt" "io/ioutil" @@ -8,15 +9,15 @@ import ( "path/filepath" "testing" "time" - "context" - "github.com/project-flogo/core/engine" - "github.com/project-flogo/microgateway/api" - test "github.com/project-flogo/microgateway/internal/testing" - "github.com/stretchr/testify/assert" + _ "github.com/project-flogo/contrib/activity/rest" + "github.com/project-flogo/core/engine" _ "github.com/project-flogo/microgateway/activity/circuitbreaker" _ "github.com/project-flogo/microgateway/activity/jwt" _ "github.com/project-flogo/microgateway/activity/ratelimiter" + "github.com/project-flogo/microgateway/api" + test "github.com/project-flogo/microgateway/internal/testing" + "github.com/stretchr/testify/assert" ) // Response is a reply form the server @@ -58,7 +59,6 @@ const reply = `{ "status":"available" }` - func testBasicGatewayApplication(t *testing.T, e engine.Engine) { defer api.ClearResources() test.Drain("9096") @@ -186,8 +186,7 @@ func TestHandlerRoutingIntegrationJSON(t *testing.T) { testHandlerRoutingApplication(t, e) } - -func testDefaultHttpPattern(t *testing.T, e engine.Engine) { +func testDefaultHTTPPattern(t *testing.T, e engine.Engine) { defer api.ClearResources() test.Drain("1234") testHandler := handler{} @@ -211,7 +210,6 @@ func testDefaultHttpPattern(t *testing.T, e engine.Engine) { err := e.Stop() assert.Nil(t, err) }() - test.Pour("9096") transport := &http.Transport{ @@ -233,7 +231,7 @@ func testDefaultHttpPattern(t *testing.T, e engine.Engine) { } body := request() - assert.NotEqual(t, 0, string(body)) + assert.NotEqual(t, 0, len(body)) } func TestDefaultHttpPatternAPI(t *testing.T) { @@ -241,9 +239,9 @@ func TestDefaultHttpPatternAPI(t *testing.T) { t.Skip("skipping Basic Gateway API integration test in short mode") } - e, err := DefaultHttpPattern() + e, err := DefaultHTTPPattern() assert.Nil(t, err) - testDefaultHttpPattern(t, e) + testDefaultHTTPPattern(t, e) } func TestDefaultHttpPatternJSON(t *testing.T) { @@ -256,5 +254,5 @@ func TestDefaultHttpPatternJSON(t *testing.T) { assert.Nil(t, err) e, err := engine.New(cfg) assert.Nil(t, err) - testDefaultHttpPattern(t, e) -} \ No newline at end of file + testDefaultHTTPPattern(t, e) +} diff --git a/examples/json/default-http-pattern/flogo.json b/examples/json/default-http-pattern/flogo.json index 6e35563..97959a8 100644 --- a/examples/json/default-http-pattern/flogo.json +++ b/examples/json/default-http-pattern/flogo.json @@ -34,12 +34,12 @@ "jwtSub": "tempuser@mail.com", "useCircuitBreaker": true, "backendUrl": "http://localhost:1234/pets", - "mode": "a", - "threshold": 2, - "timeout": 60, - "period": 60, - "method": "POST", - "content": "{\"name\":\"sally\"}" + "mode": "a", + "threshold": 2, + "timeout": 60, + "period": 60, + "method": "POST", + "content": "{\"name\":\"sally\"}" } } ]