]> code.delx.au - gnu-emacs-elpa/blob - packages/web-server/examples/012-search-bbdb.el
Merge commit '0cda39255827f283e7578cd469ae42daad9556a2' from js2-mode
[gnu-emacs-elpa] / packages / web-server / examples / 012-search-bbdb.el
1 ;;; search-bbdb.el --- search the Big Brother Data Base for a supplied name
2 ;; Copyright (C) 2014 Free Software Foundation, Inc.
3
4 (ws-start
5 (lambda (request)
6 (with-slots (process headers) request
7 (let ((name (cdr (assoc "name" headers))))
8 (unless name
9 (ws-error process "Must specify a name to search."))
10 (save-excursion
11 (unless (set-buffer (get-buffer "*BBDB*"))
12 (ws-error process "no *BBDB* buffer found"))
13 (bbdb-search-name name)
14 (if (equal (point-min) (point-max))
15 (progn
16 (ws-response-header process 404
17 '("Content-type" . "text/plain"))
18 (process-send-string process
19 "no matches found"))
20 (ws-response-header process 200
21 '("Content-type" . "text/plain"))
22 (process-send-string process (buffer-string)))))))
23 9012)