emacs-symfony-cli

Check-in [0e1640faf8]
Login
Overview
Comment:add function for get token
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 0e1640faf820c3f0c77c383b9f0c3edf4fe40d981af45aec2a5465988b703a39
User & Date: elisper on 2025-07-28 20:07:22
Other Links: manifest | tags | edit
Context
2025-08-03
12:30
Add README file check-in: 51ea04dff4 user: w96k tags: trunk
2025-07-28
20:07
add function for get token check-in: 0e1640faf8 user: elisper tags: trunk
19:04
elisp http client check-in: 2c8dd9367f user: elisper tags: trunk
Changes

Modified elisp-http-make-content.el from [58449c42a6] to [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"

Modified elisp-http-prompt.el from [7f908702cf] to [3c51eb34e7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
1
2
3
4
5
6
7
8
9
10
11
12
13














-
(defun elisp-http-prompt-api ()
  (let* ((prompt-api (propertize "апи: " 'face '(:foreground "cyan" :weight bold))))
    (read-from-minibuffer prompt-api)))

(defun elisp-http-prompt-email ()
  (let* ((prompt-register (propertize "email: " 'face '(:foreground "cyan" :weight bold))))
    (read-from-minibuffer prompt-register)))


(defun elisp-http-prompt-password ()
  (let* ((prompt-register (propertize "password: " 'face '(:foreground "red" :weight bold))))
    (read-from-minibuffer prompt-register)))


Modified elisp-http.el from [acd27bee2c] to [af6086a51c].

1
2
3
4
5
6
7




8
9
10
11
12
13
14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18







+
+
+
+







(load "~/glibc/dark_c/emacs-symfony-cli/http-content.el")
(load "~/glibc/dark_c/emacs-symfony-cli/elisp-http-style.el")
(load "~/glibc/dark_c/emacs-symfony-cli/elisp-http-prompt.el")
;;;;(global-set-key (kbd "M-m") #'(lambda () (interactive) (elisp-http) (monitor-http-buffer)))

;;(setq http-content (elisp-http-register-content))
;;(setq http-content (elisp-http-make-content))
;;(setq http-content (elisp-http-login-content))

http-content


(defun elisp-http ()
  (interactive)
  (make-network-process
   :name "elisp-post"
   :host "localhost"
   :service 8080
42
43
44
45
46
47
48
49
50
51
46
47
48
49
50
51
52










-
-
-
                           (display-buffer buf)
                           (when (timerp monitor-http-buffer--timer)
                             (cancel-timer monitor-http-buffer--timer))))))))




curl -X POST http://localhost:8000/api/login_check \
  -H "Content-Type: application/json" \
  -d '{"username": "admin@example.com", "password": "password"}'

Modified issue from [160f2f06cc] to [55775d9a02].

14
15
16
17
18
19
20





14
15
16
17
18
19
20
21
22
23
24
25







+
+
+
+
+
| `"deleted\n"`                   | Процесс был удалён                                |
| `"exit N\n"`                    | Процесс завершился с кодом `N`                    |
| `"signal SIG\n"`                | Процесс получил сигнал                            |


задача - передать токен пользователя в пост запрос
проверить на авторизации пост запрос


итак вся суть это формирование контента
давай
сначала зарегаюсь через кли просто