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