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
26d87e49
Unverified
Commit
26d87e49
authored
Sep 23, 2017
by
Clayton Coleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a negotiate method media type for use in explicit contexts
parent
7008b904
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
1 deletion
+11
-1
negotiate.go
...apiserver/pkg/endpoints/handlers/negotiation/negotiate.go
+11
-1
No files found.
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/negotiation/negotiate.go
View file @
26d87e49
...
...
@@ -40,6 +40,8 @@ func MediaTypesForSerializer(ns runtime.NegotiatedSerializer) (mediaTypes, strea
return
mediaTypes
,
streamMediaTypes
}
// NegotiateOutputMediaType negotiates the output structured media type and a serializer, or
// returns an error.
func
NegotiateOutputMediaType
(
req
*
http
.
Request
,
ns
runtime
.
NegotiatedSerializer
,
restrictions
EndpointRestrictions
)
(
MediaTypeOptions
,
runtime
.
SerializerInfo
,
error
)
{
mediaType
,
ok
:=
NegotiateMediaTypeOptions
(
req
.
Header
.
Get
(
"Accept"
),
AcceptedMediaTypesForEndpoint
(
ns
),
restrictions
)
if
!
ok
{
...
...
@@ -54,11 +56,13 @@ func NegotiateOutputMediaType(req *http.Request, ns runtime.NegotiatedSerializer
return
mediaType
,
info
,
nil
}
// NegotiateOutputSerializer returns a serializer for the output.
func
NegotiateOutputSerializer
(
req
*
http
.
Request
,
ns
runtime
.
NegotiatedSerializer
)
(
runtime
.
SerializerInfo
,
error
)
{
_
,
info
,
err
:=
NegotiateOutputMediaType
(
req
,
ns
,
DefaultEndpointRestrictions
)
return
info
,
err
}
// NegotiateOutputStreamSerializer returns a stream serializer for the given request.
func
NegotiateOutputStreamSerializer
(
req
*
http
.
Request
,
ns
runtime
.
NegotiatedSerializer
)
(
runtime
.
SerializerInfo
,
error
)
{
mediaType
,
ok
:=
NegotiateMediaTypeOptions
(
req
.
Header
.
Get
(
"Accept"
),
AcceptedMediaTypesForEndpoint
(
ns
),
DefaultEndpointRestrictions
)
if
!
ok
||
mediaType
.
Accepted
.
Serializer
.
StreamSerializer
==
nil
{
...
...
@@ -68,9 +72,15 @@ func NegotiateOutputStreamSerializer(req *http.Request, ns runtime.NegotiatedSer
return
mediaType
.
Accepted
.
Serializer
,
nil
}
// NegotiateInputSerializer returns the input serializer for the provided request.
func
NegotiateInputSerializer
(
req
*
http
.
Request
,
ns
runtime
.
NegotiatedSerializer
)
(
runtime
.
SerializerInfo
,
error
)
{
mediaTypes
:=
ns
.
SupportedMediaTypes
()
mediaType
:=
req
.
Header
.
Get
(
"Content-Type"
)
return
NegotiateInputSerializerForMediaType
(
mediaType
,
ns
)
}
// NegotiateInputSerializerForMediaType returns the appropriate serializer for the given media type or an error.
func
NegotiateInputSerializerForMediaType
(
mediaType
string
,
ns
runtime
.
NegotiatedSerializer
)
(
runtime
.
SerializerInfo
,
error
)
{
mediaTypes
:=
ns
.
SupportedMediaTypes
()
if
len
(
mediaType
)
==
0
{
mediaType
=
mediaTypes
[
0
]
.
MediaType
}
...
...
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