mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-05 00:45:29 +08:00
29 lines
570 B
Go
29 lines
570 B
Go
package responses
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
|
|
"ds2api/internal/httpapi/openai/shared"
|
|
)
|
|
|
|
func asString(v any) string {
|
|
return shared.AsString(v)
|
|
}
|
|
|
|
func decodeJSONBody(t *testing.T, body string) map[string]any {
|
|
t.Helper()
|
|
var out map[string]any
|
|
if err := json.Unmarshal([]byte(body), &out); err != nil {
|
|
t.Fatalf("decode json failed: %v, body=%s", err, body)
|
|
}
|
|
return out
|
|
}
|
|
|
|
func RegisterRoutes(r chi.Router, h *Handler) {
|
|
r.Post("/v1/responses", h.Responses)
|
|
r.Get("/v1/responses/{response_id}", h.GetResponseByID)
|
|
}
|