]> code.delx.au - gnu-emacs-elpa/blob - packages/web-server/examples/006-basic-authentication.el
Merge commit '0cda39255827f283e7578cd469ae42daad9556a2' from js2-mode
[gnu-emacs-elpa] / packages / web-server / examples / 006-basic-authentication.el
1 ;;; basic-authentication.el --- basic authentication
2 ;; Copyright (C) 2014 Free Software Foundation, Inc.
3
4 (lexical-let ((users '(("foo" . "bar")
5 ("baz" . "qux"))))
6 (ws-start
7 (ws-with-authentication
8 (lambda (request)
9 (with-slots (process headers) request
10 (let ((user (caddr (assoc :AUTHORIZATION headers))))
11 (ws-response-header process 200 '("Content-type" . "text/plain"))
12 (process-send-string process (format "welcome %s" user)))))
13 users)
14 9006))