more logging
This commit is contained in:
@@ -302,6 +302,7 @@ func openAPISpecHandler(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 {
|
||||
addCORS(w)
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
@@ -309,16 +310,19 @@ func diagramHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
id := r.URL.Query().Get("id")
|
||||
if id == "" {
|
||||
log.Printf("[diagram] missing id")
|
||||
http.Error(w, "missing id", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
xml, ok := diagramStore.data[id]
|
||||
if !ok {
|
||||
log.Printf("[diagram] id not found: %s", id)
|
||||
http.Error(w, "not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
addCORS(w)
|
||||
w.Header().Set("Content-Type", "application/xml")
|
||||
log.Printf("[diagram] served id %s bytes=%d", id, len(xml))
|
||||
_, _ = w.Write([]byte(xml))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user