MCPcopy Create free account
hub / github.com/apache/dubbo-go / ServeHTTP

Method ServeHTTP

protocol/triple/openapi/integration.go:70–101  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

68}
69
70func (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}

Callers

nothing calls this directly

Calls 5

SetMethod · 0.65
HeaderMethod · 0.65
WriteMethod · 0.65
WriteHeaderMethod · 0.45
HandleMethod · 0.45

Tested by

no test coverage detected