spring-actuator.el
author Oleksandr Gavenko <gavenkoa@gmail.com>
Thu, 30 Mar 2017 10:56:58 +0300
changeset 1525 192e86762ee5
parent 1506 4f24c53e6e38
permissions -rw-r--r--
Fix: Warning: assignment to free variable js-indent-level.


(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)