more logging

This commit is contained in:
2026-01-12 15:36:38 +11:00
parent 1aec0eba20
commit 86151eda5d

View File

@@ -302,6 +302,7 @@ func openAPISpecHandler(w http.ResponseWriter, r *http.Request) {
} }
func diagramHandler(w http.ResponseWriter, r *http.Request) { func diagramHandler(w http.ResponseWriter, r *http.Request) {
log.Printf("[diagram] %s %s from %s", r.Method, r.URL.String(), r.RemoteAddr)
if r.Method == http.MethodOptions { if r.Method == http.MethodOptions {
addCORS(w) addCORS(w)
w.WriteHeader(http.StatusNoContent) w.WriteHeader(http.StatusNoContent)
@@ -309,16 +310,19 @@ func diagramHandler(w http.ResponseWriter, r *http.Request) {
} }
id := r.URL.Query().Get("id") id := r.URL.Query().Get("id")
if id == "" { if id == "" {
log.Printf("[diagram] missing id")
http.Error(w, "missing id", http.StatusBadRequest) http.Error(w, "missing id", http.StatusBadRequest)
return return
} }
xml, ok := diagramStore.data[id] xml, ok := diagramStore.data[id]
if !ok { if !ok {
log.Printf("[diagram] id not found: %s", id)
http.Error(w, "not found", http.StatusNotFound) http.Error(w, "not found", http.StatusNotFound)
return return
} }
addCORS(w) addCORS(w)
w.Header().Set("Content-Type", "application/xml") w.Header().Set("Content-Type", "application/xml")
log.Printf("[diagram] served id %s bytes=%d", id, len(xml))
_, _ = w.Write([]byte(xml)) _, _ = w.Write([]byte(xml))
} }