MCPcopy Index your code
hub / github.com/github/copilot-sdk / _route

Method _route

python/e2e/test_copilot_request_handler_e2e.py:102–133  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

100 self.wfile.write(body)
101
102 def _route(self) -> None:
103 path = self.path.split("?", 1)[0].lower()
104 length = int(self.headers.get("content-length") or 0)
105 if length:
106 self.rfile.read(length)
107 if path.endswith("/models"):
108 self._send(
109 200,
110 "application/json",
111 json.dumps(
112 model_catalog(supported_endpoints=["/responses", "ws:/responses"])
113 ).encode("utf-8"),
114 )
115 return
116 if path.endswith("/models/session"):
117 self._send(200, "application/json", b"{}")
118 return
119 if "/policy" in path:
120 self._send(
121 200,
122 "application/json",
123 json.dumps({"state": "enabled"}).encode("utf-8"),
124 )
125 return
126 if path.endswith("/responses"):
127 self._send(200, "text/event-stream", _sse_body(HTTP_TEXT, "resp_stub_http"))
128 return
129 self._send(
130 404,
131 "application/json",
132 json.dumps({"error": "not_found", "path": path}).encode("utf-8"),
133 )
134
135 def do_GET(self): # noqa: N802
136 self._route()

Callers 2

do_GETMethod · 0.95
do_POSTMethod · 0.95

Calls 5

_sendMethod · 0.95
model_catalogFunction · 0.85
_sse_bodyFunction · 0.85
getMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected