Skip to content

Commit

Permalink
Specify content type
Browse files Browse the repository at this point in the history
  • Loading branch information
tdeebswihart committed Mar 1, 2024
1 parent c6a16c3 commit e231546
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions service/frontend/http_api_server.go
Expand Up @@ -325,8 +325,9 @@ func (h *HTTPAPIServer) incomingHeaderMatcher(headerName string) (string, bool)
}

func (h *HTTPAPIServer) registerOpenAPIDocsHandlers() {
serve := func(version int, spec []byte) func(http.ResponseWriter, *http.Request, map[string]string) {
serve := func(version int, contentType string, spec []byte) func(http.ResponseWriter, *http.Request, map[string]string) {
return func(w http.ResponseWriter, _ *http.Request, _ map[string]string) {
w.Header().Add("Content-Type", contentType)
rdr, err := gzip.NewReader(bytes.NewReader(spec))
if err != nil {
h.logger.Error("failed to initialize openapi spec reader", tag.NewInt("version", version), tag.Error(err))
Expand All @@ -342,8 +343,8 @@ func (h *HTTPAPIServer) registerOpenAPIDocsHandlers() {
}
}

h.serveMux.HandlePath(http.MethodGet, "/api/v1/swagger.json", serve(2, openapi.OpenAPIV2JSONSpec))
h.serveMux.HandlePath(http.MethodGet, "/api/v1/openapi.yaml", serve(3, openapi.OpenAPIV3YAMLSpec))
h.serveMux.HandlePath(http.MethodGet, "/api/v1/swagger.json", serve(2, "application/vnd.oai.openapi+json;version=2.0", openapi.OpenAPIV2JSONSpec))

Check failure on line 346 in service/frontend/http_api_server.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `h.serveMux.HandlePath` is not checked (errcheck)
h.serveMux.HandlePath(http.MethodGet, "/api/v1/openapi.yaml", serve(3, "application/vnd.oai.openapi;version=3.0", openapi.OpenAPIV3YAMLSpec))

Check failure on line 347 in service/frontend/http_api_server.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `h.serveMux.HandlePath` is not checked (errcheck)
}

// inlineClientConn is a [grpc.ClientConnInterface] implementation that forwards
Expand Down

0 comments on commit e231546

Please sign in to comment.