Repository navigation
Is there a way to transform a Hurl file into its "already replaced variables" version ? #5084
|
I've been building a hurl TUI to have a minimal Insomnia like experience for quite some time now and as I want to implement an history feature, I would like to be able to transform this
Into my-request_my-env-file-10-10-2026.hurl which contains Is there a command like |
Replies: 2 comments
|
You can have something you want with a combination of First, given this file: GET http://localhost:8000/captures
X-Foo: foo
HTTP 200
[Captures]
param1: header "header1"
param2: header "header2" regex "Hello (.*)!"
param3: header "header2" regex /Hello (.*)!/
# With the next captures, we test that the captured variable
# can be immediately used in the next captures + asserts
data1: body
data2: variable "data1"
[Asserts]
header "header1" == "{{param1}}"
variable "param1" == "value1"
variable "param2" == "Bob"
variable "param3" == "Bob"
variable "data2" == "Hello world!"
GET http://localhost:8000/captures-check?q={{param1}}
[QueryStringParams]
param1: {{param1}}
param2: {{param2}}
HTTP 200
GET http://localhost:8000/captures-check
[Query]
param1: {{param1}}
param2: {{param2}}
HTTP 200You can run it and with $ hurl --curl out.txt test.hurlIn out.txt, you will have: Then with $ hurlfmt --in curl > out.hurlIn out.hurl: GET http://localhost:8000/captures
X-Foo: foo
GET http://localhost:8000/captures-check?q=value1¶m1=value1¶m2=Bob
GET http://localhost:8000/captures-check?param1=value1¶m2=BobYou can notice that you will lose asserts but this modop is maybe what's approaching the most your usecase. You can also explore |
|
Thanks I'm going to try that ! |
Hi @AdmiralRazorbeard
You can have something you want with a combination of
hurlandhurlfmt.First, given this file: