Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
Project
Project
Details
Activity
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
808641c7
Commit
808641c7
authored
Feb 23, 2016
by
jackgr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Log expansion and write accept headers for tests.
parent
46984eb0
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
1 deletion
+9
-1
service.go
expandybird/service/service.go
+2
-0
expander.go
manager/manager/expander.go
+1
-1
httputil.go
util/httputil.go
+6
-0
No files found.
expandybird/service/service.go
View file @
808641c7
...
...
@@ -86,6 +86,8 @@ func NewExpansionHandler(backend expander.Expander) restful.RouteFunction {
}
util
.
LogHandlerExit
(
"expandybird"
,
http
.
StatusOK
,
"OK"
,
resp
.
ResponseWriter
)
message
:=
fmt
.
Sprintf
(
"
\n
Config:
\n
%s
\n
Layout:
\n
%s
\n
"
,
response
.
Config
,
response
.
Layout
)
util
.
LogHandlerText
(
"expandybird"
,
message
)
resp
.
WriteEntity
(
response
)
}
}
...
...
manager/manager/expander.go
View file @
808641c7
...
...
@@ -192,7 +192,7 @@ func (e *expander) expandTemplate(t *common.Template) (*ExpandedTemplate, error)
response
,
err
:=
http
.
Post
(
e
.
getBaseURL
(),
"application/json"
,
ioutil
.
NopCloser
(
bytes
.
NewReader
(
j
)))
if
err
!=
nil
{
e
:=
fmt
.
Errorf
(
"
http POST failed: %s"
,
err
)
e
:=
fmt
.
Errorf
(
"
call failed (%s) with payload:
\n
%s
\n
"
,
e
.
getBaseURL
(),
err
,
string
(
j
)
)
return
nil
,
e
}
...
...
util/httputil.go
View file @
808641c7
...
...
@@ -64,6 +64,7 @@ func NewHandlerTester(handler http.Handler) HandlerTester {
}
r
.
Header
.
Set
(
"Content-Type"
,
ctype
)
r
.
Header
.
Set
(
"Accept"
,
"*/*"
)
w
:=
httptest
.
NewRecorder
()
handler
.
ServeHTTP
(
w
,
r
)
return
w
,
nil
...
...
@@ -87,6 +88,7 @@ func NewServerTester(handler http.Handler) ServerTester {
}
r
.
Header
.
Set
(
"Content-Type"
,
ctype
)
r
.
Header
.
Set
(
"Accept"
,
"*/*"
)
return
http
.
DefaultClient
.
Do
(
r
)
}
}
...
...
@@ -112,6 +114,10 @@ func TestHandlerWithURL(handler http.Handler, method, urlString string) (*httpte
return
NewHandlerTester
(
handler
)
.
TestWithURL
(
method
,
urlString
)
}
func
LogHandlerText
(
handler
string
,
v
string
)
{
log
.
Printf
(
"%s: %s
\n
"
,
handler
,
v
)
}
// LogHandlerEntry logs the start of the given handler handling the given request.
func
LogHandlerEntry
(
handler
string
,
r
*
http
.
Request
)
{
log
.
Printf
(
"%s: handling request:%s %s
\n
"
,
handler
,
r
.
Method
,
r
.
URL
.
RequestURI
())
...
...
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