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
41fbad21
Commit
41fbad21
authored
Mar 27, 2015
by
Brendan Burns
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6062 from superbrothers/update-go-restful
Update go-restful to include emicklei/go-restful#197
parents
e4fc45c2
81399dcd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
5 deletions
+21
-5
Godeps.json
Godeps/Godeps.json
+2
-2
response.go
..._workspace/src/github.com/emicklei/go-restful/response.go
+6
-1
route.go
...ps/_workspace/src/github.com/emicklei/go-restful/route.go
+2
-2
route_test.go
...orkspace/src/github.com/emicklei/go-restful/route_test.go
+11
-0
No files found.
Godeps/Godeps.json
View file @
41fbad21
...
...
@@ -170,8 +170,8 @@
},
{
"ImportPath"
:
"github.com/emicklei/go-restful"
,
"Comment"
:
"v1.1.3-2
6-g977ac8f
"
,
"Rev"
:
"
977ac8fcbcd2ee33319246f7c91d4b426402dc70
"
"Comment"
:
"v1.1.3-2
9-gc68bc68
"
,
"Rev"
:
"
c68bc68d7689f127ab554a42378aece0ea3df4b3
"
},
{
"ImportPath"
:
"github.com/evanphx/json-patch"
,
...
...
Godeps/_workspace/src/github.com/emicklei/go-restful/response.go
View file @
41fbad21
...
...
@@ -150,6 +150,11 @@ func (r *Response) WriteAsXml(value interface{}) error {
// WriteAsJson is a convenience method for writing a value in json
func
(
r
*
Response
)
WriteAsJson
(
value
interface
{})
error
{
return
r
.
WriteJson
(
value
,
MIME_JSON
)
// no charset
}
// WriteJson is a convenience method for writing a value in Json with a given Content-Type
func
(
r
*
Response
)
WriteJson
(
value
interface
{},
contentType
string
)
error
{
var
output
[]
byte
var
err
error
...
...
@@ -165,7 +170,7 @@ func (r *Response) WriteAsJson(value interface{}) error {
if
err
!=
nil
{
return
r
.
WriteErrorString
(
http
.
StatusInternalServerError
,
err
.
Error
())
}
r
.
Header
()
.
Set
(
HEADER_ContentType
,
MIME_JSON
)
r
.
Header
()
.
Set
(
HEADER_ContentType
,
contentType
)
if
r
.
statusCode
>
0
{
// a WriteHeader was intercepted
r
.
ResponseWriter
.
WriteHeader
(
r
.
statusCode
)
}
...
...
Godeps/_workspace/src/github.com/emicklei/go-restful/route.go
View file @
41fbad21
...
...
@@ -79,8 +79,8 @@ func (r Route) matchesAccept(mimeTypesWithQuality string) bool {
if
withoutQuality
==
"*/*"
{
return
true
}
for
_
,
other
:=
range
r
.
Produces
{
if
other
==
withoutQuality
{
for
_
,
producibleType
:=
range
r
.
Produces
{
if
producibleType
==
"*/*"
||
producibleType
==
withoutQuality
{
return
true
}
}
...
...
Godeps/_workspace/src/github.com/emicklei/go-restful/route_test.go
View file @
41fbad21
...
...
@@ -31,6 +31,17 @@ func TestMatchesAcceptXml(t *testing.T) {
}
}
// accept should match produces
func
TestMatchesAcceptAny
(
t
*
testing
.
T
)
{
r
:=
Route
{
Produces
:
[]
string
{
"*/*"
}}
if
!
r
.
matchesAccept
(
"application/json"
)
{
t
.
Errorf
(
"accept should match json"
)
}
if
!
r
.
matchesAccept
(
"application/xml"
)
{
t
.
Errorf
(
"accept should match xml"
)
}
}
// content type should match consumes
func
TestMatchesContentTypeXml
(
t
*
testing
.
T
)
{
r
:=
Route
{
Consumes
:
[]
string
{
"application/xml"
}}
...
...
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