ores.doc.http-recipe.recipe

Table of Contents

One literate recipe document per model that renders an HTTP route. The document states what each endpoint does, the method and path it is addressed at, and the subject it forwards to, and each section exports its own hurl block.

The block carries a :tangle argument naming the file it exports, which is what makes one document produce one Hurl file per endpoint: given a TARGET-FILE org-babel-tangle-file redirects every matching block into one file, but with no target it honours each block's own :tangle instead. So the recipe is the literate source and the library file is its export, rather than a second document that restates it.

The request addresses a sentinel value per path parameter rather than a real key. A request that sent nothing would fail before it left the client, and a client-side refusal proves nothing about the service; a well-formed value that addresses no row reaches the router, so the recipe checks the wiring it exists to check. See org_loader._SENTINEL_VALUES.

base_url and token are Hurl variables, and the runner supplies both, so no recipe carries a host, a port or a credential. The template switches its mustache delimiters around the Hurl block for that reason: those braces belong to Hurl, not to the generator.

See the Template variable reference for the complete list of available variables and their semantics.

1. Template

The full template source. Edit here and re-tangle with compass build --direct tangle_codegen_templates to regenerate library/templates/http_recipe.org.mustache.

{{! GENERATED FILE — tangled from projects/ores.codegen/library/templates/ores.doc.http-recipe.recipe.org. Edit the org source. }}
{{#http_recipe}}
:PROPERTIES:
:ID: {{id}}
:END:
#+title: {{title}}
#+description: {{description}}
#+type: recipe
#+level: cross
#+filetags: :recipe:http:{{group}}:

{{intro}}

* Endpoints

{{#endpoints}}
** ={{heading}}=
:PROPERTIES:
:ID: {{id}}
:END:

{{commentary}}

{{#subject}}
It forwards to ={{subject}}=.
{{/subject}}

The request is:

#+begin_example
{{method_upper}} {{pattern}}
#+end_example

#+name: {{block}}
#+begin_src hurl :tangle {{name}}.hurl :exports none
{{=<% %>=}}
<%method_upper%> {{base_url}}<%pattern%>
Accept: application/json
<%#requires_session%>Authorization: Bearer {{token}}
<%/requires_session%>HTTP <%status%>
<%={{ }}=%>
#+end_src

{{/endpoints}}
{{/http_recipe}}

2. See also

Emacs 29.3 (Org mode 9.6.15)