Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
张蕾
Geth-Modification
Commits
baee8504
Commit
baee8504
authored
Nov 06, 2018
by
KimMachineGun
Committed by
Viktor Trón
Nov 06, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
swarm: modify context key (#17925)
* swarm: modify context key * gofmt sctx.go
parent
126dfde6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
16 deletions
+10
-16
sctx.go
swarm/api/http/sctx.go
+5
-9
sctx.go
swarm/sctx/sctx.go
+5
-7
No files found.
swarm/api/http/sctx.go
View file @
baee8504
...
...
@@ -7,14 +7,10 @@ import (
"github.com/ethereum/go-ethereum/swarm/sctx"
)
type
contextKey
int
const
(
uriKey
contextKey
=
iota
)
type
uriKey
struct
{}
func
GetRUID
(
ctx
context
.
Context
)
string
{
v
,
ok
:=
ctx
.
Value
(
sctx
.
HTTPRequestIDKey
)
.
(
string
)
v
,
ok
:=
ctx
.
Value
(
sctx
.
HTTPRequestIDKey
{}
)
.
(
string
)
if
ok
{
return
v
}
...
...
@@ -22,11 +18,11 @@ func GetRUID(ctx context.Context) string {
}
func
SetRUID
(
ctx
context
.
Context
,
ruid
string
)
context
.
Context
{
return
context
.
WithValue
(
ctx
,
sctx
.
HTTPRequestIDKey
,
ruid
)
return
context
.
WithValue
(
ctx
,
sctx
.
HTTPRequestIDKey
{}
,
ruid
)
}
func
GetURI
(
ctx
context
.
Context
)
*
api
.
URI
{
v
,
ok
:=
ctx
.
Value
(
uriKey
)
.
(
*
api
.
URI
)
v
,
ok
:=
ctx
.
Value
(
uriKey
{}
)
.
(
*
api
.
URI
)
if
ok
{
return
v
}
...
...
@@ -34,5 +30,5 @@ func GetURI(ctx context.Context) *api.URI {
}
func
SetURI
(
ctx
context
.
Context
,
uri
*
api
.
URI
)
context
.
Context
{
return
context
.
WithValue
(
ctx
,
uriKey
,
uri
)
return
context
.
WithValue
(
ctx
,
uriKey
{}
,
uri
)
}
swarm/sctx/sctx.go
View file @
baee8504
...
...
@@ -2,19 +2,17 @@ package sctx
import
"context"
type
ContextKey
int
const
(
HTTPRequestIDKey
ContextKey
=
iota
requestHostKey
type
(
HTTPRequestIDKey
struct
{}
requestHostKey
struct
{}
)
func
SetHost
(
ctx
context
.
Context
,
domain
string
)
context
.
Context
{
return
context
.
WithValue
(
ctx
,
requestHostKey
,
domain
)
return
context
.
WithValue
(
ctx
,
requestHostKey
{}
,
domain
)
}
func
GetHost
(
ctx
context
.
Context
)
string
{
v
,
ok
:=
ctx
.
Value
(
requestHostKey
)
.
(
string
)
v
,
ok
:=
ctx
.
Value
(
requestHostKey
{}
)
.
(
string
)
if
ok
{
return
v
}
...
...
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