Vin*_*ang 4 amazon-web-services aws-api-gateway
一些背景信息:我的设置是 browser -> api gateway -> ec2 (using spring mvc).
我想返回 200 以外的 http 状态。在谷歌搜索了很多之后,我知道我在 api 网关上做了一些配置。以下是我的配置:
Method Response,添加http状态400Integration Response->HTTP status regex,添加.*httpStatus":400.* {
"errorMessage": "{\"errorType\":\"Bad Request\",\"requestId\":\"12345\",\"httpStatus\":400,\"message\":\"you got错误\"}"
}
但是,当我测试 api(使用 api 网关中的“测试”按钮)时,它仍然返回 http 状态 200。(我希望它应该是 400)
当我将正则表达式更改为 时.*400.*,它按预期返回 http 状态 400。
当我将正则表达式更改为 时.*httpStatus.*,它返回 http 状态 200。(我希望它应该是 400)
为什么正则表达式不能.*httpStatus":400.*识别我的 json?即使我将正则表达式简化为.*httpStatus.*.
但是正则表达式.*400.*可以识别 int 400 ...
PS:我永远不会忘记在api网关上进行任何更改后部署api
这是日志
Execution log for request test-request
Wed Jul 13 15:38:22 UTC 2016 : Starting execution for request: test-invoke-request
Wed Jul 13 15:38:22 UTC 2016 : HTTP Method: POST, Resource Path: /graphql
Wed Jul 13 15:38:22 UTC 2016 : Method request path: {}
Wed Jul 13 15:38:22 UTC 2016 : Method request query string: {}
Wed Jul 13 15:38:22 UTC 2016 : Method request headers: {}
Wed Jul 13 15:38:22 UTC 2016 : Method request body before transformations: null
Wed Jul 13 15:38:22 UTC 2016 : Endpoint request URI: http://awseb-e-e-AWSEBLoa-1OSQBKG0O3J75-968940376.ap-northeast-1.elb.amazonaws.com/graphql
Wed Jul 13 15:38:22 UTC 2016 : Endpoint request headers: {x-amzn-apigateway-api-id=kymhygbqwa, Accept=application/json, User-Agent=AmazonAPIGateway_kymhygbqwa}
Wed Jul 13 15:38:22 UTC 2016 : Endpoint request body after transformations: null
Wed Jul 13 15:38:22 UTC 2016 : Endpoint response body before transformations: {"errorMessage":"{\"errorType\":\"Bad Request\",\"requestId\":\"12345\",\"httpStatus\":400,\"message\":\"you got error\"}"}
Wed Jul 13 15:38:22 UTC 2016 : Endpoint response headers: {date=Wed, 13 Jul 2016 15:38:22 GMT, server=Apache-Coyote/1.1, expires=0, transfer-encoding=chunked, access-control-allow-headers=Origin, X-Requested-With, Content-Type, Accept, x-frame-options=DENY, access-control-allow-methods=POST, GET, PUT, OPTIONS, DELETE, pragma=no-cache, access-control-allow-origin=*, access-control-max-age=3600, x-content-type-options=nosniff, x-xss-protection=1; mode=block, content-type=application/json;charset=UTF-8, connection=keep-alive, cache-control=no-cache, no-store, max-age=0, must-revalidate}
Wed Jul 13 15:38:22 UTC 2016 : Method response body after transformations: {"errorMessage":"{\"errorType\":\"Bad Request\",\"requestId\":\"12345\",\"httpStatus\":400,\"message\":\"you got error\"}"}
Wed Jul 13 15:38:22 UTC 2016 : Method response headers: {Content-Type=application/json}
Wed Jul 13 15:38:22 UTC 2016 : Successfully completed execution
Wed Jul 13 15:38:22 UTC 2016 : Method completed with status: 200
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4003 次 |
| 最近记录: |