From c8a8ea62160ad9fc069b8e82526c31e0bcaf64cd Mon Sep 17 00:00:00 2001 From: Carlo Sciolla Date: Wed, 29 May 2019 13:24:01 +0200 Subject: [PATCH] Replace variables in file paths before parsing This change allows to specify a filename as a variable, e.g.: ``` :test-file = ./test-data.json GET http://localhost:8000/process < :test-file ``` This allows to easily switch between different payloads for the same API with minimal efforts. --- restclient.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/restclient.el b/restclient.el index a5e6e99..2790b0a 100644 --- a/restclient.el +++ b/restclient.el @@ -452,7 +452,7 @@ The buffer contains the raw HTTP response sent by the server." (when (looking-at restclient-empty-line-regexp) (forward-line)) (let* ((cmax (restclient-current-max)) - (entity (restclient-parse-body (buffer-substring (min (point) cmax) cmax) vars)) + (entity (restclient-parse-body (restclient-replace-all-in-string vars (buffer-substring (min (point) cmax) cmax)) vars)) (url (restclient-replace-all-in-string vars url))) (apply func method url headers entity args)))))) @@ -549,7 +549,7 @@ Optional argument STAY-IN-WINDOW do not move focus to response buffer if t." (end-of-line) ;; If the overlays at this point have 'invisible set, toggling ;; must make the region visible. Else it must hide the region - + ;; This part of code is from org-hide-block-toggle method of ;; Org mode (let ((overlays (overlays-at (point))))