返回 DeepSeek-Reasonix
question_answer.go
根目录 / internal / serve / question_answer.go
1 package serve
2
3 import (
4 "encoding/json"
5 "net/http"
6
7 "reasonix/internal/event"
8 )
9
10 // answer responds to an ask_request only after its transition is durable.
11 func (s *Server) answer(w http.ResponseWriter, r *http.Request) {
12 var body struct {
13 ID string `json:"id"`
14 Answers []event.AskAnswer `json:"answers"`
15 }
16 if err := json.NewDecoder(r.Body).Decode(&body); err != nil || body.ID == "" {
17 http.Error(w, "missing id", http.StatusBadRequest)
18 return
19 }
20 if err := s.ctl().AnswerQuestionChecked(body.ID, body.Answers); err != nil {
21 http.Error(w, err.Error(), http.StatusServiceUnavailable)
22 return
23 }
24 w.WriteHeader(http.StatusNoContent)
25 }
26
26 lines GO