mirror of
https://github.com/morten-olsen/http.md.git
synced 2026-02-08 00:46:28 +01:00
fix: yaml parsing
This commit is contained in:
@@ -89,7 +89,7 @@ _(Note: Actual headers and some response fields might vary.)_
|
|||||||
|
|
||||||
HTTP requests are defined in fenced code blocks annotated with `http`. The syntax is similar to the raw HTTP format:
|
HTTP requests are defined in fenced code blocks annotated with `http`. The syntax is similar to the raw HTTP format:
|
||||||
|
|
||||||
```http disable
|
```
|
||||||
<METHOD> <URL>
|
<METHOD> <URL>
|
||||||
<Header-Name>: <Header-Value>
|
<Header-Name>: <Header-Value>
|
||||||
...
|
...
|
||||||
@@ -132,10 +132,17 @@ You can assign a unique ID to an `http` request block. This allows you to:
|
|||||||
1. Reference its specific response in a `::response` directive.
|
1. Reference its specific response in a `::response` directive.
|
||||||
2. Access its request and response data in [Templating](https://www.google.com/search?q=%23templating-with-handlebars) via the `requests` and `responses` dictionaries.
|
2. Access its request and response data in [Templating](https://www.google.com/search?q=%23templating-with-handlebars) via the `requests` and `responses` dictionaries.
|
||||||
|
|
||||||
To add an ID, include `id=yourUniqueId` in the `http` block's info string:
|
To add an ID, include `#yourUniqueId` or `id=yourUniqueId` in the `http` block's info string:
|
||||||
|
|
||||||
::raw-md[./examples/with-multiple-requests.md]
|
::raw-md[./examples/with-multiple-requests.md]
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Output</summary>
|
||||||
|
|
||||||
|
::raw-md[./examples/with-multiple-requests.md]{render}
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
## Templating with Handlebars
|
## Templating with Handlebars
|
||||||
|
|
||||||
`http.md` uses [Handlebars](https://handlebarsjs.com/) for templating, allowing you to create dynamic content within your markdown files. You can inject data from request responses, input variables, and other requests into your HTTP blocks or general markdown text.
|
`http.md` uses [Handlebars](https://handlebarsjs.com/) for templating, allowing you to create dynamic content within your markdown files. You can inject data from request responses, input variables, and other requests into your HTTP blocks or general markdown text.
|
||||||
|
|||||||
@@ -2,16 +2,16 @@
|
|||||||
|
|
||||||
First, create a resource:
|
First, create a resource:
|
||||||
|
|
||||||
```http id=createUser
|
```http #createUser,format=yaml
|
||||||
POST https://httpbin.org/post
|
POST https://httpbin.org/post
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
|
|
||||||
{"username": "alpha"}
|
username: alpha
|
||||||
```
|
```
|
||||||
|
|
||||||
Then, fetch a different resource:
|
Then, fetch a different resource:
|
||||||
|
|
||||||
```http id=getItem
|
```http #getItem
|
||||||
GET https://httpbin.org/get?item=123
|
GET https://httpbin.org/get?item=123
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ const httpHandler: ExecutionHandler = ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
node.value = content;
|
node.value = [head, parsedBody].filter(Boolean).join('\n\n');
|
||||||
node.meta = undefined;
|
node.meta = undefined;
|
||||||
|
|
||||||
context.addRequest({
|
context.addRequest({
|
||||||
|
|||||||
Reference in New Issue
Block a user