MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / ServeHTTP

Method ServeHTTP

mcp-server/server.go:97–122  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

95}
96
97func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
98 var sid string
99 if r.URL.Path == OpenServiceMCPPath {
100 sid = r.Header.Get("X-Service-Id")
101 if sid == "" {
102 http.NotFound(w, r)
103 return
104 }
105 } else {
106 id, err := genPath(r.URL.Path)
107 if err != nil {
108 w.WriteHeader(http.StatusBadRequest)
109 w.Write([]byte(err.Error()))
110 return
111 }
112 sid = id
113 }
114
115 ser, has := s.Get(sid)
116 if has {
117 ser.ServeHTTP(w, r)
118 return
119 }
120 http.NotFound(w, r)
121 return
122}
123
124func genPath(path string) (sid string, err error) {
125 path = strings.TrimSuffix(path, "/")

Callers 10

AppMCPHandleMethod · 0.45
AppHandleStreamHTTPMethod · 0.45
GlobalMCPHandleMethod · 0.45
handleSSEMethod · 0.45
MCPHandleMethod · 0.45
handleMessageMethod · 0.45
ServeHTTPMethod · 0.45
ServeHTTPFunction · 0.45

Calls 5

GetMethod · 0.95
genPathFunction · 0.85
WriteHeaderMethod · 0.80
WriteMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected