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
81399dcd
Commit
81399dcd
authored
Mar 28, 2015
by
Kazuki Suda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update go-restful to include emicklei/go-restful#197
parent
a4bf91c8
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 @
81399dcd
...
@@ -170,8 +170,8 @@
...
@@ -170,8 +170,8 @@
},
},
{
{
"ImportPath"
:
"github.com/emicklei/go-restful"
,
"ImportPath"
:
"github.com/emicklei/go-restful"
,
"Comment"
:
"v1.1.3-2
6-g977ac8f
"
,
"Comment"
:
"v1.1.3-2
9-gc68bc68
"
,
"Rev"
:
"
977ac8fcbcd2ee33319246f7c91d4b426402dc70
"
"Rev"
:
"
c68bc68d7689f127ab554a42378aece0ea3df4b3
"
},
},
{
{
"ImportPath"
:
"github.com/evanphx/json-patch"
,
"ImportPath"
:
"github.com/evanphx/json-patch"
,
...
...
Godeps/_workspace/src/github.com/emicklei/go-restful/response.go
View file @
81399dcd
...
@@ -150,6 +150,11 @@ func (r *Response) WriteAsXml(value interface{}) error {
...
@@ -150,6 +150,11 @@ func (r *Response) WriteAsXml(value interface{}) error {
// WriteAsJson is a convenience method for writing a value in json
// WriteAsJson is a convenience method for writing a value in json
func
(
r
*
Response
)
WriteAsJson
(
value
interface
{})
error
{
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
output
[]
byte
var
err
error
var
err
error
...
@@ -165,7 +170,7 @@ func (r *Response) WriteAsJson(value interface{}) error {
...
@@ -165,7 +170,7 @@ func (r *Response) WriteAsJson(value interface{}) error {
if
err
!=
nil
{
if
err
!=
nil
{
return
r
.
WriteErrorString
(
http
.
StatusInternalServerError
,
err
.
Error
())
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
if
r
.
statusCode
>
0
{
// a WriteHeader was intercepted
r
.
ResponseWriter
.
WriteHeader
(
r
.
statusCode
)
r
.
ResponseWriter
.
WriteHeader
(
r
.
statusCode
)
}
}
...
...
Godeps/_workspace/src/github.com/emicklei/go-restful/route.go
View file @
81399dcd
...
@@ -79,8 +79,8 @@ func (r Route) matchesAccept(mimeTypesWithQuality string) bool {
...
@@ -79,8 +79,8 @@ func (r Route) matchesAccept(mimeTypesWithQuality string) bool {
if
withoutQuality
==
"*/*"
{
if
withoutQuality
==
"*/*"
{
return
true
return
true
}
}
for
_
,
other
:=
range
r
.
Produces
{
for
_
,
producibleType
:=
range
r
.
Produces
{
if
other
==
withoutQuality
{
if
producibleType
==
"*/*"
||
producibleType
==
withoutQuality
{
return
true
return
true
}
}
}
}
...
...
Godeps/_workspace/src/github.com/emicklei/go-restful/route_test.go
View file @
81399dcd
...
@@ -31,6 +31,17 @@ func TestMatchesAcceptXml(t *testing.T) {
...
@@ -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
// content type should match consumes
func
TestMatchesContentTypeXml
(
t
*
testing
.
T
)
{
func
TestMatchesContentTypeXml
(
t
*
testing
.
T
)
{
r
:=
Route
{
Consumes
:
[]
string
{
"application/xml"
}}
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