emacs-symfony-cli

Diff
Login

Differences From Artifact [58449c42a6]:

To Artifact [5d2c78ee84]:


1
2
3

4
5
6
7
8
9
10
1
2

3
4
5
6
7
8
9
10


-
+







;;(load "~/glibc/dark_c/emacs-symfony-cli/http-content.el")

;;;(global-set-key (kbd "M-m") #'(lambda () (interactive) (elisp-http-content)))
;;;(global-set-key (kbd "M-m") #'(lambda () (interactive) (elisp-http-login-content)))

(setq http-token "")

(defun elisp-http-get-header ()
  (if-let* ((auth-header (unless (or (null http-token)
                                     (string= http-token ""))
                           (list (cons "Authorization" (concat "Bearer " http-token)))))
30
31
32
33
34
35
36
37

38
39
40
41
42
43
44
30
31
32
33
34
35
36

37
38
39
40
41
42
43
44







-
+







(defun elisp-http-get-line ()
  (let* ((_path (elisp-http-prompt-api))
		 (path (format "GET /%s HTTP/1.1" _path)))
	path))

;;;(elisp-http-register-line)

(defun elisp-http-make-content (method)
(defun elisp-http-make-content ()
  (let ((request-line (elisp-http-set-request-line)))
    (concat
     request-line "\n"
     (mapconcat (lambda (x)
                  (format "%s: %s" (car x) (cdr x)))
                my-headers
                "\n"))))
60
61
62
63
64
65
66























60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
                     "\n")))
    (concat request-line "\n"
            header-block "\n\n"
            json-body)))

;; Пример использования:
;;;(elisp-http-register-content)

(defun elisp-http-login-content ()
  "Generate HTTP request content for login with JSON payload using 'email'."
  (let* ((email (elisp-http-prompt-email))
         (password (elisp-http-prompt-password))
         (request-line (format "POST /%s HTTP/1.1" (elisp-http-prompt-api)))
         (json-body (json-encode `(("email" . ,email) ("password" . ,password))))
         (headers (append my-headers
                          (list (cons "Content-Length"
                                      (number-to-string (string-bytes json-body))))))
         (header-block
          (mapconcat (lambda (x) (format "%s: %s" (car x) (cdr x)))
                     headers
                     "\n")))
    (concat request-line "\n"
            header-block "\n\n"
            json-body)))
;;;(elisp-http-login-content)

;;;(setq youo (elisp-http-login-content))

;;;           "email": "somex@gmail.com",
;;;           "password": "test1234"