Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
CAP
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
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
CAP
Commits
5e71b8cd
Commit
5e71b8cd
authored
Apr 12, 2018
by
Savorboard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add TryExtractTracingHeaders
parent
af1b1ec6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
1 deletion
+25
-1
Helper.cs
src/DotNetCore.CAP/Infrastructure/Helper.cs
+25
-1
No files found.
src/DotNetCore.CAP/Infrastructure/Helper.cs
View file @
5e71b8cd
...
...
@@ -2,7 +2,9 @@
// Licensed under the MIT License. See License.txt in the project root for license information.
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.Linq
;
using
System.Reflection
;
using
DotNetCore.CAP.Diagnostics
;
using
Newtonsoft.Json
;
...
...
@@ -94,7 +96,29 @@ namespace DotNetCore.CAP.Infrastructure
public
static
string
AddTracingHeaderProperty
(
string
json
,
TracingHeaders
headers
)
{
var
jObject
=
ToJObject
(
headers
);
return
AddJsonProperty
(
json
,
"TracingHeaders"
,
jObject
);
return
AddJsonProperty
(
json
,
nameof
(
TracingHeaders
),
jObject
);
}
public
static
bool
TryExtractTracingHeaders
(
string
json
,
out
TracingHeaders
headers
,
out
string
removedHeadersJson
)
{
var
jObj
=
JObject
.
Parse
(
json
);
var
jToken
=
jObj
[
nameof
(
TracingHeaders
)];
if
(
jToken
!=
null
)
{
headers
=
new
TracingHeaders
();
foreach
(
var
item
in
jToken
.
ToObject
<
Dictionary
<
string
,
string
>>())
{
headers
.
Add
(
item
.
Key
,
item
.
Value
);
}
jObj
.
Remove
(
nameof
(
TracingHeaders
));
removedHeadersJson
=
jObj
.
ToString
();
return
true
;
}
headers
=
null
;
removedHeadersJson
=
null
;
return
false
;
}
public
static
bool
IsInnerIP
(
string
ipAddress
)
...
...
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