Closed xuchunyang closed 4 years ago
It looks like this could be solved by applying a user-defined function right before the request is sent. Take a look here: https://github.com/federicotdn/verb/issues/25#issuecomment-645492662. Let me know if it helps!
Great! It works for one heading, e.g.,
* List Buckets :verb:
:PROPERTIES:
:Verb-Map-Request: chunyang-verb-cos5-insert-authorization
:END:
GET https://service.cos.myqcloud.com/
(defun chunyang-verb-cos5-insert-authorization (request-spec)
(pcase-let (((eieio method url headers) request-spec))
(cl-assert (not (member "Authorization" headers)))
(pcase-let ((`(,path . ,query) (url-path-and-query url)))
(cl-callf2 cons
(cons "Authorization" (cos5--sign method path query headers))
(oref request-spec headers))
request-spec)))
However, it does not inherit, right? e.g., this does not work
* COS :verb:
:PROPERTIES:
:Verb-Map-Request: chunyang-verb-cos5-insert-authorization
:END:
** Service 接口
template https://service.cos.myqcloud.com
*** GET Service(List Buckets)
GET /
I've tried (setq org-use-property-inheritance t)
but it does not help.
You are right, the property is not inherited. I thought org-entry-get
would respect the value of org-use-property-inheritance
but it doesn't by default, unless INHERIT
is set to 'selective
. I'll push a fix now.
Ok! I've pushed a commit to master. Once it's on MELPA you should be able to use org-use-property-inheritance
set to t
and make it work.
Thanks. I'll try again after upgrade.
Works perfectly.
There is an API that requires the Authorization header to be computed at request time, it needs Method, URL and other Headers to compute Authorization, e.g.,
but I do not want to fill the arguments by hand, It seems I can try
(verb--request-spec-from-hierarchy)
although it's a private functionbut when I use it in verb, it reports
which is not very surprise, it seems both I and verb try to compute Authorization. Any ideas?