mylisp/spring-actuator.el
author Oleksandr Gavenko <gavenkoa@gmail.com>
Wed, 16 Jun 2021 12:50:08 +0300
changeset 1734 ae2c6a001464
parent 1666 06937ff1ec5f
permissions -rw-r--r--
Add some standard places to PATH if they are not set by login script. Rearrange the order of paths so system's are first, user's are last. For Cygwin this helps with Cygwin's paths to be situated before "C:/Windows" (Emacs is not started from a login shell on Windows!).


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