Initial project scaffold

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-09 14:36:35 +08:00
co-authored by Cursor
commit 6323e70e49
39 changed files with 8664 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
package httpapi
import (
"encoding/json"
"fmt"
"net/http"
)
func writeJSON(w http.ResponseWriter, status int, value any) {
w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(status)
_ = json.NewEncoder(w).Encode(value)
}
func writeError(w http.ResponseWriter, status int, message string) {
writeJSON(w, status, map[string]any{
"error": map[string]any{
"message": message,
"status": status,
},
})
}
func sendSSE(w http.ResponseWriter, event string, payload any) {
bytes, _ := json.Marshal(payload)
_, _ = fmt.Fprintf(w, "event: %s\n", event)
_, _ = fmt.Fprintf(w, "data: %s\n\n", bytes)
}