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
bd38dd4d
Commit
bd38dd4d
authored
Jun 27, 2017
by
Antoine Pelisse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
openapi: Read Accept-Content to send gzip if needed
parent
9120d58f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
13 deletions
+17
-13
openapi_handler.go
...rc/k8s.io/apiserver/pkg/server/openapi/openapi_handler.go
+17
-13
No files found.
staging/src/k8s.io/apiserver/pkg/server/openapi/openapi_handler.go
View file @
bd38dd4d
...
@@ -26,6 +26,7 @@ import (
...
@@ -26,6 +26,7 @@ import (
"strings"
"strings"
"time"
"time"
"github.com/NYTimes/gziphandler"
"github.com/go-openapi/spec"
"github.com/go-openapi/spec"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/proto"
"github.com/googleapis/gnostic/OpenAPIv2"
"github.com/googleapis/gnostic/OpenAPIv2"
...
@@ -75,19 +76,22 @@ func RegisterOpenAPIService(openapiSpec *spec.Swagger, servePath string, mux *ge
...
@@ -75,19 +76,22 @@ func RegisterOpenAPIService(openapiSpec *spec.Swagger, servePath string, mux *ge
for
_
,
file
:=
range
files
{
for
_
,
file
:=
range
files
{
path
:=
servePathBase
+
file
.
ext
path
:=
servePathBase
+
file
.
ext
getData
:=
file
.
getData
getData
:=
file
.
getData
mux
.
HandleFunc
(
path
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
mux
.
Handle
(
path
,
gziphandler
.
GzipHandler
(
http
.
HandlerFunc
(
if
r
.
URL
.
Path
!=
path
{
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
w
.
WriteHeader
(
http
.
StatusNotFound
)
if
r
.
URL
.
Path
!=
path
{
w
.
Write
([]
byte
(
"Path not found!"
))
w
.
WriteHeader
(
http
.
StatusNotFound
)
return
w
.
Write
([]
byte
(
"Path not found!"
))
}
return
o
.
update
(
r
)
}
data
:=
getData
()
o
.
update
(
r
)
etag
:=
computeEtag
(
data
)
data
:=
getData
()
w
.
Header
()
.
Set
(
"Etag"
,
etag
)
etag
:=
computeEtag
(
data
)
// ServeContent will take care of caching using eTag.
w
.
Header
()
.
Set
(
"Etag"
,
etag
)
http
.
ServeContent
(
w
,
r
,
path
,
o
.
lastModified
,
bytes
.
NewReader
(
data
))
})
// ServeContent will take care of caching using eTag.
http
.
ServeContent
(
w
,
r
,
path
,
o
.
lastModified
,
bytes
.
NewReader
(
data
))
}),
))
}
}
return
&
o
,
nil
return
&
o
,
nil
...
...
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