Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
request-proxy
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Jira
Jira
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ui
request-proxy
Commits
7096cc5c
Commit
7096cc5c
authored
May 14, 2019
by
郝聪敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改logger输出规则
parent
8f3c6dd9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
6 deletions
+9
-6
index.js
index.js
+8
-5
package.json
package.json
+1
-1
No files found.
index.js
View file @
7096cc5c
...
@@ -30,7 +30,6 @@ module.exports = function (options) {
...
@@ -30,7 +30,6 @@ module.exports = function (options) {
const
curlDefault
=
{
const
curlDefault
=
{
followRedirect
:
false
,
followRedirect
:
false
,
json
:
true
,
json
:
true
,
time
:
false
,
timeout
:
options
.
timeout
timeout
:
options
.
timeout
}
}
...
@@ -44,13 +43,18 @@ module.exports = function (options) {
...
@@ -44,13 +43,18 @@ module.exports = function (options) {
}
}
const
pipeDefault
=
{
const
pipeDefault
=
{
time
:
false
,
timeout
:
options
.
timeout
timeout
:
options
.
timeout
}
}
const
httpAgent
=
new
Agent
(
options
.
agent
);
const
httpAgent
=
new
Agent
(
options
.
agent
);
const
httpsAgent
=
new
HttpsAgent
();
const
httpsAgent
=
new
HttpsAgent
();
const
logger
=
(
option
,
response
)
=>
{
if
(
options
.
logger
)
{
options
.
logger
.
info
(
JSON
.
stringify
({
host
:
option
.
uri
,
...(
response
&&
response
.
timings
)}))
}
}
return
async
function
(
ctx
,
next
)
{
return
async
function
(
ctx
,
next
)
{
if
(
ctx
.
pipe
||
ctx
.
curl
)
return
next
()
if
(
ctx
.
pipe
||
ctx
.
curl
)
return
next
()
...
@@ -82,6 +86,7 @@ module.exports = function (options) {
...
@@ -82,6 +86,7 @@ module.exports = function (options) {
resolve
(
err
)
resolve
(
err
)
}
}
}
else
{
}
else
{
logger
(
option
,
response
)
resolve
(
extra
.
rawRes
?
response
:
{
resolve
(
extra
.
rawRes
?
response
:
{
status
:
response
.
statusCode
,
status
:
response
.
statusCode
,
headers
:
response
.
headers
,
headers
:
response
.
headers
,
...
@@ -110,9 +115,7 @@ module.exports = function (options) {
...
@@ -110,9 +115,7 @@ module.exports = function (options) {
return
new
Promise
(
function
(
resolve
,
reject
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
let
r
=
ctx
.
req
.
pipe
(
request
(
option
,
function
(
err
,
response
)
{
let
r
=
ctx
.
req
.
pipe
(
request
(
option
,
function
(
err
,
response
)
{
if
(
option
.
time
&&
options
.
logger
)
{
logger
(
option
,
response
)
options
.
logger
.
info
(
option
.
uri
,
JSON
.
stringify
(
response
&&
response
.
timings
||
''
))
}
}))
}))
r
.
on
(
'
error
'
,
function
(
err
)
{
r
.
on
(
'
error
'
,
function
(
err
)
{
reject
(
err
);
reject
(
err
);
...
...
package.json
View file @
7096cc5c
{
{
"name"
:
"request-proxy"
,
"name"
:
"request-proxy"
,
"version"
:
"1.2.
1
"
,
"version"
:
"1.2.
2
"
,
"description"
:
""
,
"description"
:
""
,
"main"
:
"index.js"
,
"main"
:
"index.js"
,
"scripts"
:
{
"scripts"
:
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment