调试工具

This commit is contained in:
候学杰 2019-01-30 16:06:41 +08:00
parent 99f5b6c8f8
commit 69e7fd3f5c
8 changed files with 94 additions and 225 deletions

242
composer.lock generated
View File

@ -18,13 +18,7 @@
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/inflector/zipball/5527a48b7313d15261292c149e55e26eae771b0a", "url": "https://api.github.com/repos/doctrine/inflector/zipball/5527a48b7313d15261292c149e55e26eae771b0a",
"reference": "5527a48b7313d15261292c149e55e26eae771b0a", "reference": "5527a48b7313d15261292c149e55e26eae771b0a",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"php": "^7.1" "php": "^7.1"
@ -91,13 +85,7 @@
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/407b0cb880ace85c9b63c5f9551db498cb2d50ba", "url": "https://api.github.com/repos/guzzle/guzzle/zipball/407b0cb880ace85c9b63c5f9551db498cb2d50ba",
"reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba", "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"guzzlehttp/promises": "^1.0", "guzzlehttp/promises": "^1.0",
@ -162,13 +150,7 @@
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646", "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646",
"reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646", "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"php": ">=5.5.0" "php": ">=5.5.0"
@ -219,13 +201,7 @@
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/9f83dded91781a01c63574e387eaa769be769115", "url": "https://api.github.com/repos/guzzle/psr7/zipball/9f83dded91781a01c63574e387eaa769be769115",
"reference": "9f83dded91781a01c63574e387eaa769be769115", "reference": "9f83dded91781a01c63574e387eaa769be769115",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"php": ">=5.4.0", "php": ">=5.4.0",
@ -282,23 +258,17 @@
}, },
{ {
"name": "illuminate/contracts", "name": "illuminate/contracts",
"version": "v5.7.20", "version": "v5.7.23",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/illuminate/contracts.git", "url": "https://github.com/illuminate/contracts.git",
"reference": "758927e5e925c1d442a1faaa1356675ceba0194c" "reference": "3d67e2d7c9087ae3a2a53d9b102697e5f482d6d0"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/illuminate/contracts/zipball/758927e5e925c1d442a1faaa1356675ceba0194c", "url": "https://api.github.com/repos/illuminate/contracts/zipball/3d67e2d7c9087ae3a2a53d9b102697e5f482d6d0",
"reference": "758927e5e925c1d442a1faaa1356675ceba0194c", "reference": "3d67e2d7c9087ae3a2a53d9b102697e5f482d6d0",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"php": "^7.1.3", "php": "^7.1.3",
@ -328,11 +298,11 @@
], ],
"description": "The Illuminate Contracts package.", "description": "The Illuminate Contracts package.",
"homepage": "https://laravel.com", "homepage": "https://laravel.com",
"time": "2018-11-15T13:49:08+00:00" "time": "2019-01-09T10:34:49+00:00"
}, },
{ {
"name": "illuminate/filesystem", "name": "illuminate/filesystem",
"version": "v5.7.20", "version": "v5.7.23",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/illuminate/filesystem.git", "url": "https://github.com/illuminate/filesystem.git",
@ -342,13 +312,7 @@
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/illuminate/filesystem/zipball/19ba2ac5f85b7505d7c2bf6307d10633f9f3c6b0", "url": "https://api.github.com/repos/illuminate/filesystem/zipball/19ba2ac5f85b7505d7c2bf6307d10633f9f3c6b0",
"reference": "19ba2ac5f85b7505d7c2bf6307d10633f9f3c6b0", "reference": "19ba2ac5f85b7505d7c2bf6307d10633f9f3c6b0",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"illuminate/contracts": "5.7.*", "illuminate/contracts": "5.7.*",
@ -390,23 +354,17 @@
}, },
{ {
"name": "illuminate/http", "name": "illuminate/http",
"version": "v5.7.20", "version": "v5.7.23",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/illuminate/http.git", "url": "https://github.com/illuminate/http.git",
"reference": "4592866213f7283a345aae2b04d0685450fd2d73" "reference": "28f7a7ffa944d49b63023e99c1fda2e5fb56df0e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/illuminate/http/zipball/4592866213f7283a345aae2b04d0685450fd2d73", "url": "https://api.github.com/repos/illuminate/http/zipball/28f7a7ffa944d49b63023e99c1fda2e5fb56df0e",
"reference": "4592866213f7283a345aae2b04d0685450fd2d73", "reference": "28f7a7ffa944d49b63023e99c1fda2e5fb56df0e",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"illuminate/session": "5.7.*", "illuminate/session": "5.7.*",
@ -438,11 +396,11 @@
], ],
"description": "The Illuminate Http package.", "description": "The Illuminate Http package.",
"homepage": "https://laravel.com", "homepage": "https://laravel.com",
"time": "2019-01-04T23:18:04+00:00" "time": "2019-01-12T14:14:21+00:00"
}, },
{ {
"name": "illuminate/session", "name": "illuminate/session",
"version": "v5.7.20", "version": "v5.7.23",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/illuminate/session.git", "url": "https://github.com/illuminate/session.git",
@ -452,13 +410,7 @@
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/illuminate/session/zipball/7e2a7bcf01a16e03c2f97bffccc7e7f0fd0ed9da", "url": "https://api.github.com/repos/illuminate/session/zipball/7e2a7bcf01a16e03c2f97bffccc7e7f0fd0ed9da",
"reference": "7e2a7bcf01a16e03c2f97bffccc7e7f0fd0ed9da", "reference": "7e2a7bcf01a16e03c2f97bffccc7e7f0fd0ed9da",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"illuminate/contracts": "5.7.*", "illuminate/contracts": "5.7.*",
@ -498,7 +450,7 @@
}, },
{ {
"name": "illuminate/support", "name": "illuminate/support",
"version": "v5.7.20", "version": "v5.7.23",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/illuminate/support.git", "url": "https://github.com/illuminate/support.git",
@ -508,13 +460,7 @@
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/illuminate/support/zipball/ea3f30dd824bba52bcff4290dc7431b0ffb478e1", "url": "https://api.github.com/repos/illuminate/support/zipball/ea3f30dd824bba52bcff4290dc7431b0ffb478e1",
"reference": "ea3f30dd824bba52bcff4290dc7431b0ffb478e1", "reference": "ea3f30dd824bba52bcff4290dc7431b0ffb478e1",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"doctrine/inflector": "^1.1", "doctrine/inflector": "^1.1",
@ -573,13 +519,7 @@
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/influxdata/influxdb-php/zipball/570bd5cdedb9b1c1628dceea5785bc40e08f7e48", "url": "https://api.github.com/repos/influxdata/influxdb-php/zipball/570bd5cdedb9b1c1628dceea5785bc40e08f7e48",
"reference": "570bd5cdedb9b1c1628dceea5785bc40e08f7e48", "reference": "570bd5cdedb9b1c1628dceea5785bc40e08f7e48",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"guzzlehttp/guzzle": "^6.0", "guzzlehttp/guzzle": "^6.0",
@ -639,13 +579,7 @@
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/itxq/api-doc-php/zipball/79ac71cf09da49491cfb92722d6f6e13ad8f6482", "url": "https://api.github.com/repos/itxq/api-doc-php/zipball/79ac71cf09da49491cfb92722d6f6e13ad8f6482",
"reference": "79ac71cf09da49491cfb92722d6f6e13ad8f6482", "reference": "79ac71cf09da49491cfb92722d6f6e13ad8f6482",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"php": ">=5.6.0" "php": ">=5.6.0"
@ -681,13 +615,7 @@
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266", "url": "https://api.github.com/repos/Seldaek/monolog/zipball/bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266",
"reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266", "reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"php": ">=5.3.0", "php": ">=5.3.0",
@ -765,13 +693,7 @@
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/cd324b98bc30290f233dd0e75e6ce49f7ab2a6c9", "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/cd324b98bc30290f233dd0e75e6ce49f7ab2a6c9",
"reference": "cd324b98bc30290f233dd0e75e6ce49f7ab2a6c9", "reference": "cd324b98bc30290f233dd0e75e6ce49f7ab2a6c9",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"php": ">=5.3.9", "php": ">=5.3.9",
@ -829,13 +751,7 @@
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
"reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"php": ">=5.3.0" "php": ">=5.3.0"
@ -884,13 +800,7 @@
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"php": ">=5.3.0" "php": ">=5.3.0"
@ -940,13 +850,7 @@
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", "url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd",
"reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"php": ">=5.3.0" "php": ">=5.3.0"
@ -993,13 +897,7 @@
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
"reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"php": ">=5.3.0" "php": ">=5.3.0"
@ -1047,13 +945,7 @@
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/5601c8a83fbba7ef674a7369456d12f1e0d0eafa", "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/5601c8a83fbba7ef674a7369456d12f1e0d0eafa",
"reference": "5601c8a83fbba7ef674a7369456d12f1e0d0eafa", "reference": "5601c8a83fbba7ef674a7369456d12f1e0d0eafa",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"php": ">=5.3" "php": ">=5.3"
@ -1093,13 +985,7 @@
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/contracts/zipball/1aa7ab2429c3d594dd70689604b5cf7421254cdf", "url": "https://api.github.com/repos/symfony/contracts/zipball/1aa7ab2429c3d594dd70689604b5cf7421254cdf",
"reference": "1aa7ab2429c3d594dd70689604b5cf7421254cdf", "reference": "1aa7ab2429c3d594dd70689604b5cf7421254cdf",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"php": "^7.1.3" "php": "^7.1.3"
@ -1167,13 +1053,7 @@
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/debug/zipball/64cb33c81e37d19b7715d4a6a4d49c1c382066dd", "url": "https://api.github.com/repos/symfony/debug/zipball/64cb33c81e37d19b7715d4a6a4d49c1c382066dd",
"reference": "64cb33c81e37d19b7715d4a6a4d49c1c382066dd", "reference": "64cb33c81e37d19b7715d4a6a4d49c1c382066dd",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"php": "^7.1.3", "php": "^7.1.3",
@ -1229,13 +1109,7 @@
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/887de6d34c86cf0cb6cbf910afb170cdb743cb5e", "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/887de6d34c86cf0cb6cbf910afb170cdb743cb5e",
"reference": "887de6d34c86cf0cb6cbf910afb170cdb743cb5e", "reference": "887de6d34c86cf0cb6cbf910afb170cdb743cb5e",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"php": "^7.1.3", "php": "^7.1.3",
@ -1299,13 +1173,7 @@
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/9094d69e8c6ee3fe186a0ec5a4f1401e506071ce", "url": "https://api.github.com/repos/symfony/finder/zipball/9094d69e8c6ee3fe186a0ec5a4f1401e506071ce",
"reference": "9094d69e8c6ee3fe186a0ec5a4f1401e506071ce", "reference": "9094d69e8c6ee3fe186a0ec5a4f1401e506071ce",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"php": "^7.1.3" "php": "^7.1.3"
@ -1354,13 +1222,7 @@
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/a633d422a09242064ba24e44a6e1494c5126de86", "url": "https://api.github.com/repos/symfony/http-foundation/zipball/a633d422a09242064ba24e44a6e1494c5126de86",
"reference": "a633d422a09242064ba24e44a6e1494c5126de86", "reference": "a633d422a09242064ba24e44a6e1494c5126de86",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"php": "^7.1.3", "php": "^7.1.3",
@ -1414,13 +1276,7 @@
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/83de6543328917c18d5498eeb6bb6d36f7aab31b", "url": "https://api.github.com/repos/symfony/http-kernel/zipball/83de6543328917c18d5498eeb6bb6d36f7aab31b",
"reference": "83de6543328917c18d5498eeb6bb6d36f7aab31b", "reference": "83de6543328917c18d5498eeb6bb6d36f7aab31b",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"php": "^7.1.3", "php": "^7.1.3",
@ -1509,13 +1365,7 @@
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19", "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19",
"reference": "e3d826245268269cd66f8326bd8bc066687b4a19", "reference": "e3d826245268269cd66f8326bd8bc066687b4a19",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"php": ">=5.3.3" "php": ">=5.3.3"
@ -1573,13 +1423,7 @@
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/c79c051f5b3a46be09205c73b80b346e4153e494", "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/c79c051f5b3a46be09205c73b80b346e4153e494",
"reference": "c79c051f5b3a46be09205c73b80b346e4153e494", "reference": "c79c051f5b3a46be09205c73b80b346e4153e494",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"php": ">=5.3.3" "php": ">=5.3.3"
@ -1638,13 +1482,7 @@
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/939fb792d73f2ce80e6ae9019d205fc480f1c9a0", "url": "https://api.github.com/repos/symfony/translation/zipball/939fb792d73f2ce80e6ae9019d205fc480f1c9a0",
"reference": "939fb792d73f2ce80e6ae9019d205fc480f1c9a0", "reference": "939fb792d73f2ce80e6ae9019d205fc480f1c9a0",
"shasum": "", "shasum": ""
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"php": "^7.1.3", "php": "^7.1.3",

View File

@ -4,10 +4,11 @@ namespace JsonRpc;
use GuzzleHttp\Exception\ServerException; use GuzzleHttp\Exception\ServerException;
use JsonRpc\Exception\RpcServerException; use JsonRpc\Exception\RpcServerException;
use JsonRpc\Server\JsonRpcBase;
use Monolog\Handler\StreamHandler; use Monolog\Handler\StreamHandler;
use Monolog\Logger; use Monolog\Logger;
class Client class Client extends JsonRpc
{ {
/** /**
* all configuration information * all configuration information
@ -48,7 +49,6 @@ class Client
$this->server_config = $this->config['client'][$k]; $this->server_config = $this->config['client'][$k];
$default = [ $default = [
'app' => $k,
'timeout' => 3, 'timeout' => 3,
'allow_redirects' => false, 'allow_redirects' => false,
]; ];
@ -93,7 +93,6 @@ class Client
protected function post($payload) protected function post($payload)
{ {
try { try {
$headers = [ $headers = [
'X-Client-App' => $this->config['app'], 'X-Client-App' => $this->config['app'],
]; ];
@ -103,14 +102,19 @@ class Client
'json' => $payload, 'json' => $payload,
]); ]);
} catch (ServerException $e) { } catch (ServerException $e) {
throw new RpcServerException($e->getMessage(), $e->getCode()); $ex = new RpcServerException(self::ErrorMsg[JsonRpc::Rpc_Error_Internal_Error], JsonRpc::Rpc_Error_Internal_Error);
if (env("APP_DEBUG") == true) {
$resp = $e->getResponse();
$ex->setResponse($e->getResponse());
}
throw $ex;
} }
try { try {
$body = \GuzzleHttp\json_decode($resp->getBody(), true); $body = \GuzzleHttp\json_decode($resp->getBody(), true);
app('rpc.logger')->info("client_response", $body); app('rpc.logger')->info("client_response", $body);
if (empty($body)) { if (empty($body)) {
throw new RpcServerException('http response empty', 500); throw new RpcServerException('http response empty', JsonRpc::Rpc_Error_System_Error);
} }
if (isset($body['error']) && isset($body['error']['code']) && isset($body['error']['message'])) { if (isset($body['error']) && isset($body['error']['code']) && isset($body['error']['message'])) {
$message = is_array($body['error']['message']) ? json_encode($body['error']['message']) : $body['error']['message']; $message = is_array($body['error']['message']) ? json_encode($body['error']['message']) : $body['error']['message'];
@ -121,7 +125,11 @@ class Client
} catch (\InvalidArgumentException $e) { } catch (\InvalidArgumentException $e) {
app('rpc.logger')->error('client_decode_error', array_merge($this->server_config, $payload)); app('rpc.logger')->error('client_decode_error', array_merge($this->server_config, $payload));
throw new RpcServerException('json decode error', -32700); $ex = new RpcServerException($e->getMessage(), JsonRpc::Rpc_Error_Parse_Error);
if (env("APP_DEBUG") == true) {
$ex->setResponse($resp);
}
throw $ex;
} }
} }

View File

@ -4,4 +4,16 @@ namespace JsonRpc\Exception;
class RpcServerException extends \Exception class RpcServerException extends \Exception
{ {
protected $response;
public function setResponse($resp)
{
$this->response = $resp;
}
public function getResponse()
{
return $this->response;
}
} }

View File

@ -1,8 +1,8 @@
<?php <?php
namespace JsonRpc\Server; namespace JsonRpc;
class JsonRpcBase class JsonRpc
{ {
const Rpc_Error_Parse_Error = -32700; //Parse error语法解析错误 服务端接收到无效的json。该错误发送于服务器尝试解析json文本 const Rpc_Error_Parse_Error = -32700; //Parse error语法解析错误 服务端接收到无效的json。该错误发送于服务器尝试解析json文本
const Rpc_Error_Invalid_Request = -32600; //Invalid Request无效请求 发送的json不是一个有效的请求对象。 const Rpc_Error_Invalid_Request = -32600; //Invalid Request无效请求 发送的json不是一个有效的请求对象。

View File

@ -4,8 +4,9 @@ namespace JsonRpc\Server;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use JsonRpc\Exception\RpcServerException; use JsonRpc\Exception\RpcServerException;
use JsonRpc\JsonRpc;
class JsonRpcMethod extends JsonRpcBase class JsonRpcMethod extends JsonRpc
{ {
protected $id; protected $id;
protected $request; protected $request;

View File

@ -5,8 +5,9 @@ namespace JsonRpc\Server;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use JsonRpc\JsonRpc;
class JsonRpcServer extends JsonRpcBase class JsonRpcServer extends JsonRpc
{ {
/** /**
* @var Request * @var Request

View File

@ -35,21 +35,26 @@ class JsonRpcTool
*/ */
$view = view(); $view = view();
$params = json_decode($request->input('params',"[\r\n]"), true); $params = json_decode($request->input('params', "[\r\n]"), true);
$method = $request->input('method'); $method = $request->input('method');
if ($request->method() == Request::METHOD_POST) { if ($request->method() == Request::METHOD_POST) {
try { try {
$result = app('rpc.'.$this->config['name'])->call($method, $params); $result = app('rpc.' . $this->config['name'])->call($method, $params);
$view->share('result', json_encode($result, JSON_PRETTY_PRINT)); $view->share('result', json_encode($result, JSON_PRETTY_PRINT));
} catch (RpcServerException $exception) { } catch (RpcServerException $exception) {
$view->share('error', ['code' => $exception->getCode(), 'message' => $exception->getMessage()]); $resp = $exception->getResponse();
$view->share('error', [
'code' => $exception->getCode(),
'message' => $exception->getMessage(),
'resp' => $resp]
);
} }
} }
$methods = $this->getMethods(); $methods = $this->getMethods();
$view->share('method',$method); $view->share('method', $method);
$view->share('endpoint', $this->getEndpoint()); $view->share('endpoint', $this->getEndpoint());
$view->share('methods', $methods); $view->share('methods', $methods);
$view->share('params', json_encode($params,JSON_PRETTY_PRINT)); $view->share('params', json_encode($params, JSON_PRETTY_PRINT));
foreach ($methods as $name => $class) { foreach ($methods as $name => $class) {
$desc[$name] = $this->desc($class[0], $class[1]); $desc[$name] = $this->desc($class[0], $class[1]);
@ -83,6 +88,6 @@ class JsonRpcTool
$reflector = $this->classes[$class]; $reflector = $this->classes[$class];
} }
return str_replace("/**\n",'',$reflector->getMethod($method)->getDocComment()); return str_replace("/**\n", '', $reflector->getMethod($method)->getDocComment());
} }
} }

View File

@ -29,10 +29,10 @@
</a> </a>
</li> </li>
{{--<li class="nav-item">--}} {{--<li class="nav-item">--}}
{{--<a class="nav-link" href="#">--}} {{--<a class="nav-link" href="#">--}}
{{--<span data-feather="file"></span>--}} {{--<span data-feather="file"></span>--}}
{{--abc--}} {{--abc--}}
{{--</a>--}} {{--</a>--}}
{{--</li>--}} {{--</li>--}}
</ul> </ul>
</div> </div>
@ -77,9 +77,13 @@
</form> </form>
<div class="row col-md-12"> <div class="row col-md-12">
@if( !empty($error) ) @if( !empty($error) )
<div id='alert' class="alert alert-danger" role="alert"> <div id='alert' class="alert alert-danger" role="alert" style="width: 100%">
RpcServerException: {{$error['message']}} with code {{$error['code']}} code&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: {{$error['code']}} <br>
message : {{$error['message']}}
</div> </div>
<h5>返回内容:</h5>
<iframe style="width: 100%;height: 500px;border: none;" srcdoc='{{$error['resp']->getBody()}}'></iframe>
<hr>
@endif @endif
@if( !empty($result) ) @if( !empty($result) )
<h5>Result:</h5> <h5>Result:</h5>
@ -104,7 +108,7 @@
var editor = ace.edit("editor"); var editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai"); editor.setTheme("ace/theme/monokai");
editor.session.setMode("ace/mode/json"); editor.session.setMode("ace/mode/json");
editor.on('change',function(e){ editor.on('change', function (e) {
$('#params').val(editor.getValue()) $('#params').val(editor.getValue())
}) })
</script> </script>