Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
d3bac22a
Commit
d3bac22a
authored
Mar 29, 2018
by
Cao Shufeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
set right Content-Type for configz
parent
3cb73605
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
5 deletions
+8
-5
configz.go
pkg/util/configz/configz.go
+2
-2
configz_test.go
pkg/util/configz/configz_test.go
+6
-3
No files found.
pkg/util/configz/configz.go
View file @
d3bac22a
...
@@ -19,7 +19,6 @@ package configz
...
@@ -19,7 +19,6 @@ package configz
import
(
import
(
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"io"
"net/http"
"net/http"
"sync"
"sync"
)
)
...
@@ -74,7 +73,7 @@ func handle(w http.ResponseWriter, r *http.Request) {
...
@@ -74,7 +73,7 @@ func handle(w http.ResponseWriter, r *http.Request) {
}
}
}
}
func
write
(
w
io
.
Writer
)
error
{
func
write
(
w
http
.
Response
Writer
)
error
{
var
b
[]
byte
var
b
[]
byte
var
err
error
var
err
error
func
()
{
func
()
{
...
@@ -85,6 +84,7 @@ func write(w io.Writer) error {
...
@@ -85,6 +84,7 @@ func write(w io.Writer) error {
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"error marshaling json: %v"
,
err
)
return
fmt
.
Errorf
(
"error marshaling json: %v"
,
err
)
}
}
w
.
Header
()
.
Set
(
"Content-Type"
,
"application/json"
)
_
,
err
=
w
.
Write
(
b
)
_
,
err
=
w
.
Write
(
b
)
return
err
return
err
}
}
pkg/util/configz/configz_test.go
View file @
d3bac22a
...
@@ -44,7 +44,7 @@ func TestConfigz(t *testing.T) {
...
@@ -44,7 +44,7 @@ func TestConfigz(t *testing.T) {
t
.
Fatalf
(
"err: %v"
,
err
)
t
.
Fatalf
(
"err: %v"
,
err
)
}
}
if
string
(
body
)
!=
`{"testing":"blah"}`
{
if
string
(
body
)
!=
`{"testing":"blah"}`
{
t
.
Fatalf
(
"unexpected output: %
v"
,
err
)
t
.
Fatalf
(
"unexpected output: %
s"
,
body
)
}
}
v
.
Set
(
"bing"
)
v
.
Set
(
"bing"
)
...
@@ -58,7 +58,7 @@ func TestConfigz(t *testing.T) {
...
@@ -58,7 +58,7 @@ func TestConfigz(t *testing.T) {
t
.
Fatalf
(
"err: %v"
,
err
)
t
.
Fatalf
(
"err: %v"
,
err
)
}
}
if
string
(
body
)
!=
`{"testing":"bing"}`
{
if
string
(
body
)
!=
`{"testing":"bing"}`
{
t
.
Fatalf
(
"unexpected output: %
v"
,
err
)
t
.
Fatalf
(
"unexpected output: %
s"
,
body
)
}
}
Delete
(
"testing"
)
Delete
(
"testing"
)
...
@@ -72,6 +72,9 @@ func TestConfigz(t *testing.T) {
...
@@ -72,6 +72,9 @@ func TestConfigz(t *testing.T) {
t
.
Fatalf
(
"err: %v"
,
err
)
t
.
Fatalf
(
"err: %v"
,
err
)
}
}
if
string
(
body
)
!=
`{}`
{
if
string
(
body
)
!=
`{}`
{
t
.
Fatalf
(
"unexpected output: %v"
,
err
)
t
.
Fatalf
(
"unexpected output: %s"
,
body
)
}
if
resp
.
Header
.
Get
(
"Content-Type"
)
!=
"application/json"
{
t
.
Fatalf
(
"unexpected Content-Type: %s"
,
resp
.
Header
.
Get
(
"Content-Type"
))
}
}
}
}
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