A HTTP request lib for Emacs with flexible callback dispatch.
grapnel is an HTTP request library that uses a curl subprocess and offers flexible callback dispatch. Not only can you pass in an alist of request outcomes to callback functions (see below) but you can also override the dispatch function itself if the default one doesn’t suit your needs. Further, grapnel will build the query string, request data (i.e., POST body), and headers from alists that are passed in.
See the inline docs for more information.
(require 'package) (add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/") t) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) (package-initialize)
Then you can install it:
M-x package-refresh-contents M-x package-install RET grapnel RET
Download the source or clone the repo and add the following to ~/.emacs.d/init.el:
(add-to-list 'load-path "path/to/grapnel") (require 'grapnel)
(grapnel-retrieve-url url `((401 . (lambda (response headers) (error "Unauthorized!"))) (success . ,success-callback) (failure . (lambda (response headers) (error "Failed with: %s for %s" (cadr (assoc "response-code" headers)) ,url))) (error . (lambda (response) (error "Error: %s" response)))) "GET" '((some-param . "some-value")))
Copyright © 2013 David Leatherman.
Files are licensed under the same license as Emacs unless otherwise specified. See the file LICENSE for details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.