spring-actuator.el
changeset 1666 06937ff1ec5f
parent 1665 3685e2321a9b
child 1667 7f70095fbf32
equal deleted inserted replaced
1665:3685e2321a9b 1666:06937ff1ec5f
     1 
       
     2 (require 'json)
       
     3 (require 'js)
       
     4 
       
     5 (defvar spring-actuator-server-history nil)
       
     6 (defvar spring-actuator-last-server "http://localhost:8080")
       
     7 (defvar spring-actuator-path-history nil)
       
     8 (defvar spring-actuator-path-completion
       
     9   '("actuator" "auditevents" "autoconfig" "beans" "configprops" "dump" "env" "features" "flyway" "health" "heapdump"
       
    10     "info" "jolokia" "liquibase" "logfile" "loggers" "mappings" "metrics" "trace"))
       
    11 
       
    12 ;;;###autoload
       
    13 (defun spring-actuator (server path)
       
    14   (interactive (list (read-string "Server: " spring-actuator-last-server 'spring-actuator-server-history)
       
    15                      (completing-read "Path: " spring-actuator-path-completion nil nil "" 'spring-actuator-path-history)))
       
    16   (setq spring-actuator-last-server server)
       
    17   (let ( (bufname (format "actuator: %s" path)) )
       
    18     (when (get-buffer bufname)
       
    19       (kill-buffer bufname))
       
    20     (switch-to-buffer (url-retrieve-synchronously (format "%s/%s" server path)))
       
    21     (rename-buffer bufname)
       
    22     (goto-char (point-min))
       
    23     (re-search-forward "^$" nil 'move)
       
    24     (forward-char)
       
    25     (delete-region (point-min) (point))
       
    26     (json-pretty-print-buffer)
       
    27     (goto-char (point-min))
       
    28     (if (fboundp 'json-mode)
       
    29         (json-mode)
       
    30       (js-mode))
       
    31     (setq-local js-indent-level 2)))
       
    32 
       
    33 (provide 'spring-actuator)