INNER CODE UNIT · Go
chatCompletionsHandler
easegress-io/easegress · scripts/benchmark/aigateway/llm/main.go:134
func chatCompletionsHandler(w http.ResponseWriter, r *http.Request) {
fmt.Printf("Received request: %+v\n", r)
if r.Method != http.MethodPost {
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
return
}
var req ChatCompletionRequest
body, err := io.ReadAll(r.Body)
if err != nil {
http.Error(w, "bad request", http.StatusBadRequest)
return
}
defer r.Body.Close()
// Parse JSON
if err := json.Unmarshal(body, &req); err != nil {