{"action":"created","issue":{"url":"https://api.github.com/repos/devopsfaith/krakend-ce/issues/31","repository_url":"https://api.github.com/repos/devopsfaith/krakend-ce","labels_url":"https://api.github.com/repos/devopsfaith/krakend-ce/issues/31/labels{/name}","comments_url":"https://api.github.com/repos/devopsfaith/krakend-ce/issues/31/comments","events_url":"https://api.github.com/repos/devopsfaith/krakend-ce/issues/31/events","html_url":"https://github.com/devopsfaith/krakend-ce/issues/31","id":351350930,"node_id":"MDU6SXNzdWUzNTEzNTA5MzA=","number":31,"title":"Send error response according to Backend response","user":{"login":"ricmoreira","id":11554091,"node_id":"MDQ6VXNlcjExNTU0MDkx","avatar_url":"https://avatars2.githubusercontent.com/u/11554091?v=4","gravatar_id":"","url":"https://api.github.com/users/ricmoreira","html_url":"https://github.com/ricmoreira","followers_url":"https://api.github.com/users/ricmoreira/followers","following_url":"https://api.github.com/users/ricmoreira/following{/other_user}","gists_url":"https://api.github.com/users/ricmoreira/gists{/gist_id}","starred_url":"https://api.github.com/users/ricmoreira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ricmoreira/subscriptions","organizations_url":"https://api.github.com/users/ricmoreira/orgs","repos_url":"https://api.github.com/users/ricmoreira/repos","events_url":"https://api.github.com/users/ricmoreira/events{/privacy}","received_events_url":"https://api.github.com/users/ricmoreira/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2018-08-16T20:10:27Z","updated_at":"2018-12-11T08:38:44Z","closed_at":"2018-08-17T10:38:31Z","author_association":"NONE","body":"Hello, \r\n\r\nI'm finding difficult to get an working example for getting error responses according to backend response  and not the default 500 error response.\r\n\r\nI've implemented my Gateway according to your Gin example and, at the moment, it is like this:\r\n\r\n```golang\r\npackage main\r\n\r\nimport (\r\n\t\"flag\"\r\n\t\"log\"\r\n\t\"os\"\r\n\t\"time\"\r\n\r\n\t\"github.com/gin-gonic/gin\"\r\n\t\"gopkg.in/gin-contrib/cors.v1\"\r\n\r\n\t\"api_gateway_admin/middleware\"\r\n\r\n\t\"github.com/devopsfaith/krakend/config\"\r\n\t\"github.com/devopsfaith/krakend/logging\"\r\n\t\"github.com/devopsfaith/krakend/proxy\"\r\n\tkrakendgin \"github.com/devopsfaith/krakend/router/gin\"\r\n)\r\n\r\nfunc main() {\r\n\tport := flag.Int(\"p\", 0, \"Port of the service\")\r\n\tlogLevel := flag.String(\"l\", \"ERROR\", \"Logging level\")\r\n\tdebug := flag.Bool(\"d\", false, \"Enable the debug\")\r\n\tconfigFile := flag.String(\"c\", \"{{path to file}}/configuration.json\", \"Path to the configuration filename\")\r\n\tflag.Parse()\r\n\r\n\tparser := config.NewParser()\r\n\tserviceConfig, err := parser.Parse(*configFile)\r\n\tif err != nil {\r\n\t\tlog.Fatal(\"ERROR:\", err.Error())\r\n\t}\r\n\tserviceConfig.Debug = serviceConfig.Debug || *debug\r\n\tif *port != 0 {\r\n\t\tserviceConfig.Port = *port\r\n\t}\r\n\r\n\tlogger, err := logging.NewLogger(*logLevel, os.Stdout, \"[KRAKEND]\")\r\n\tif err != nil {\r\n\t\tlog.Println(\"ERROR:\", err.Error())\r\n\t\treturn\r\n\t}\r\n\r\n\trouterFactory := krakendgin.NewFactory(krakendgin.Config{\r\n\t\tEngine:         gin.Default(),\r\n\t\tProxyFactory:   customProxyFactory{logger, proxy.DefaultFactory(logger)},\r\n\t\tLogger:         logger,\r\n\t\tHandlerFactory: krakendgin.EndpointHandler,\r\n\t\tMiddlewares: []gin.HandlerFunc{\r\n\t\t\tcors.New(cors.Config{\r\n\t\t\t\tAllowOrigins: []string{\"http://localhost:4200\", \"http://127.0.0.1:4200\", \"http://localhost:8089\", \"http://localhost:8069\", \"http://localhost:8080\", \"http://localhost:8099\"},\r\n\t\t\t\tAllowMethods: []string{\"PUT\", \"PATCH\", \"POST\", \"GET\", \"DELETE\", \"OPTIONS\"},\r\n\t\t\t\tAllowHeaders: []string{\"Accept\",\r\n\t\t\t\t\t\"Accept-Encoding\",\r\n\t\t\t\t\t\"Accept-Language\",\r\n\t\t\t\t\t\"access-control-allow-origin\",\r\n\t\t\t\t\t\"Access-Control-Request-Headers\",\r\n\t\t\t\t\t\"Access-Control-Request-Method\",\r\n\t\t\t\t\t\"authorization\",\r\n\t\t\t\t\t\"Cache-Control\",\r\n\t\t\t\t\t\"Connection\",\r\n\t\t\t\t\t\"Content-Type\",\r\n\t\t\t\t\t\"Host\",\r\n\t\t\t\t\t\"If-Modified-Since\",\r\n\t\t\t\t\t\"Keep-Alive\",\r\n\t\t\t\t\t\"Key\",\r\n\t\t\t\t\t\"Origin\",\r\n\t\t\t\t\t\"Pragma\",\r\n\t\t\t\t\t\"User-Agent\",\r\n\t\t\t\t\t\"X-Custom-Header\"},\r\n\t\t\t\tExposeHeaders:    []string{\"Content-Length\", \"Content-Type\"},\r\n\t\t\t\tAllowCredentials: true,\r\n\t\t\t\tMaxAge:           48 * time.Hour,\r\n\t\t\t}),\r\n\t\t\tmiddleware.JwtCheck(),\r\n\t\t},\r\n\t})\r\n\r\n\trouterFactory.New().Run(serviceConfig)\r\n}\r\n\r\n// customProxyFactory adds a logging middleware wrapping the internal factory\r\ntype customProxyFactory struct {\r\n\tlogger  logging.Logger\r\n\tfactory proxy.Factory\r\n}\r\n\r\n// New implements the Factory interface\r\nfunc (cf customProxyFactory) New(cfg *config.EndpointConfig) (p proxy.Proxy, err error) {\r\n\tp, err = cf.factory.New(cfg)\r\n\tif err == nil {\r\n\t\tp = proxy.NewLoggingMiddleware(cf.logger, cfg.Endpoint)(p)\r\n\t}\r\n\treturn\r\n}\r\n\r\n```\r\n\r\nCould you please help me out on what should I change here?\r\nThank you.\r\n "},"comment":{"url":"https://api.github.com/repos/devopsfaith/krakend-ce/issues/comments/446116980","html_url":"https://github.com/devopsfaith/krakend-ce/issues/31#issuecomment-446116980","issue_url":"https://api.github.com/repos/devopsfaith/krakend-ce/issues/31","id":446116980,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NjExNjk4MA==","user":{"login":"dominiksimek","id":7128168,"node_id":"MDQ6VXNlcjcxMjgxNjg=","avatar_url":"https://avatars1.githubusercontent.com/u/7128168?v=4","gravatar_id":"","url":"https://api.github.com/users/dominiksimek","html_url":"https://github.com/dominiksimek","followers_url":"https://api.github.com/users/dominiksimek/followers","following_url":"https://api.github.com/users/dominiksimek/following{/other_user}","gists_url":"https://api.github.com/users/dominiksimek/gists{/gist_id}","starred_url":"https://api.github.com/users/dominiksimek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dominiksimek/subscriptions","organizations_url":"https://api.github.com/users/dominiksimek/orgs","repos_url":"https://api.github.com/users/dominiksimek/repos","events_url":"https://api.github.com/users/dominiksimek/events{/privacy}","received_events_url":"https://api.github.com/users/dominiksimek/received_events","type":"User","site_admin":false},"created_at":"2018-12-11T08:38:44Z","updated_at":"2018-12-11T08:38:44Z","author_association":"NONE","body":"Great, it works well.\r\n\r\nHowever, I have an issue with endpoint used to sign JWT (github.com/devopsfaith/krakend-jose/signer). Signed token is not returned from Krakend when using Backend _\"encoding\": \"no-op\"_ (it returns only empty JSON).\r\nOn the other hand, response from Krakend contains valid json with signed token when using Backend _\"encoding\": \"json\"_. But _StatusCode_ from Krakend response can be only 200 or 400. In the case of unsuccessful user authentication (e.g. wrong password), my backend sends 401 with additional JSON in the response body. Is it possible to proxy such response from backend through Krakend?\r\n\r\nThank you"}}
{"actor":{"display_login":"dominiksimek"}}