HTTP request lib for Emacs built on curl with flexible callback dispatch
Emacs Lisp
Latest commit fbd0f9a Nov 21, 2015 @leathekd Merge pull request #5 from syohex/update-url
Update MELPA URL
Failed to load latest commit information.
COPYING Version bump to 0.5.2, minor readme updates Jun 21, 2013
grapnel.el Version 0.5.3 Oct 1, 2013
grapnel_test.el Update tests to reflect changes Sep 29, 2013
readme.org Update MELPA URL Nov 22, 2015

readme.org

grapnel

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.

Installation

Via Marmalade/Melpa

(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

Manually (via git)

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)

Usage Example

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

License

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/.