Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
http-echo
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
testing
http-echo
Commits
2248b004
Commit
2248b004
authored
Apr 08, 2019
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Substringing more efficient and go-like.
parent
8a527944
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletion
+3
-1
main.go
main.go
+3
-1
No files found.
main.go
View file @
2248b004
...
...
@@ -46,6 +46,7 @@ import (
var
(
hostname
string
logger
*
log
.
Logger
lenPrefix
int
address
=
flag
.
String
(
"address"
,
":7357"
,
"listen address"
)
logF
=
flag
.
String
(
"log"
,
""
,
"log file (default stdout)"
)
setPrefix
=
flag
.
String
(
"set_prefix"
,
"X-Set-"
,
...
...
@@ -81,7 +82,7 @@ func handle(resp http.ResponseWriter, req *http.Request) {
if
!
strings
.
HasPrefix
(
reqHdr
,
*
setPrefix
)
{
continue
}
newHdr
:=
string
([]
byte
(
reqHdr
)[
len
(
*
setPrefix
)
:
])
newHdr
:=
reqHdr
[
lenPrefix
:
]
for
_
,
val
:=
range
vals
{
respHdr
.
Add
(
newHdr
,
val
)
}
...
...
@@ -129,6 +130,7 @@ func main() {
hostname
=
"unknown"
}
lenPrefix
=
len
(
*
setPrefix
)
mux
:=
http
.
NewServeMux
()
mux
.
HandleFunc
(
"/"
,
handle
)
logger
.
Println
(
"listening at:"
,
*
address
)
...
...
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