summaryrefslogtreecommitdiff
path: root/examples/006-basic-authentication.el
blob: 0d3f354bc252ba06ed35b805806813d9a6b8261d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
;;; basic-authentication.el --- basic authentication  -*- lexical-binding: t; -*-
;; Copyright (C) 2014-2020  Free Software Foundation, Inc.

(let ((users '(("foo" . "bar")
               ("baz" . "qux"))))
  (ws-start
   (ws-with-authentication
    (lambda (request)
      (with-slots (process headers) request
        (let ((user (caddr (assoc :AUTHORIZATION headers))))
          (ws-response-header process 200 '("Content-type" . "text/plain"))
          (process-send-string process (format "welcome %s" user)))))
    users)
   9006))