NEXUS-1: Initial commit of Nexus

This commit is contained in:
Blake Ridgway
2026-07-14 05:53:25 -05:00
commit 16fe2bf928
22 changed files with 1739 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
package handler
import (
"encoding/json"
"net/http"
)
// respondJSON writes a JSON response with the given status code.
func respondJSON(w http.ResponseWriter, status int, data any) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(status)
if data != nil {
if err := json.NewEncoder(w).Encode(data); err != nil {
http.Error(w, `{"error":"failed to encode response"}`, http.StatusInternalServerError)
}
}
}
// respondError writes a JSON error response.
func respondError(w http.ResponseWriter, status int, message string) {
respondJSON(w, status, map[string]string{"error": message})
}