mylisp/spring-actuator.el
changeset 1666 06937ff1ec5f
parent 1525 192e86762ee5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mylisp/spring-actuator.el	Sat Jan 02 00:33:04 2021 +0200
@@ -0,0 +1,33 @@
+
+(require 'json)
+(require 'js)
+
+(defvar spring-actuator-server-history nil)
+(defvar spring-actuator-last-server "http://localhost:8080")
+(defvar spring-actuator-path-history nil)
+(defvar spring-actuator-path-completion
+  '("actuator" "auditevents" "autoconfig" "beans" "configprops" "dump" "env" "features" "flyway" "health" "heapdump"
+    "info" "jolokia" "liquibase" "logfile" "loggers" "mappings" "metrics" "trace"))
+
+;;;###autoload
+(defun spring-actuator (server path)
+  (interactive (list (read-string "Server: " spring-actuator-last-server 'spring-actuator-server-history)
+                     (completing-read "Path: " spring-actuator-path-completion nil nil "" 'spring-actuator-path-history)))
+  (setq spring-actuator-last-server server)
+  (let ( (bufname (format "actuator: %s" path)) )
+    (when (get-buffer bufname)
+      (kill-buffer bufname))
+    (switch-to-buffer (url-retrieve-synchronously (format "%s/%s" server path)))
+    (rename-buffer bufname)
+    (goto-char (point-min))
+    (re-search-forward "^$" nil 'move)
+    (forward-char)
+    (delete-region (point-min) (point))
+    (json-pretty-print-buffer)
+    (goto-char (point-min))
+    (if (fboundp 'json-mode)
+        (json-mode)
+      (js-mode))
+    (setq-local js-indent-level 2)))
+
+(provide 'spring-actuator)