(w http.ResponseWriter, r *http.Request)
| 68 | } |
| 69 | |
| 70 | func (h *HTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { |
| 71 | if h.integration == nil || h.integration.service == nil || !h.integration.service.config.Enabled { |
| 72 | w.Header().Set("Content-Type", "application/json") |
| 73 | w.WriteHeader(http.StatusNotFound) |
| 74 | _, _ = w.Write([]byte(`{"message":"OpenAPI is not available","status":"404"}`)) |
| 75 | return |
| 76 | } |
| 77 | |
| 78 | if content, contentType, ok := h.integration.swaggerHandler.Handle(r); ok { |
| 79 | w.Header().Set("Content-Type", contentType) |
| 80 | w.WriteHeader(http.StatusOK) |
| 81 | _, _ = w.Write([]byte(content)) |
| 82 | return |
| 83 | } |
| 84 | |
| 85 | if content, contentType, ok := h.integration.redocHandler.Handle(r); ok { |
| 86 | w.Header().Set("Content-Type", contentType) |
| 87 | w.WriteHeader(http.StatusOK) |
| 88 | _, _ = w.Write([]byte(content)) |
| 89 | return |
| 90 | } |
| 91 | |
| 92 | if content, contentType, ok := h.integration.requestHandler.Handle(r); ok { |
| 93 | w.Header().Set("Content-Type", contentType) |
| 94 | w.WriteHeader(http.StatusOK) |
| 95 | _, _ = w.Write([]byte(content)) |
| 96 | return |
| 97 | } |
| 98 | |
| 99 | w.WriteHeader(http.StatusNotFound) |
| 100 | _, _ = w.Write([]byte("Not Found")) |
| 101 | } |
nothing calls this directly
no test coverage detected