-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global variable support and Generate env JSON option #24
Changes from 15 commits
cca4db6
0c87717
84a4848
4dd0f23
655a236
548e43e
48f3154
d12b69b
549affb
a66383b
be15f49
a1b1b33
caece11
36d2d4f
ffc95e9
82690f1
c19afee
ce1359c
251ddef
cbe799f
58fbc92
2b505fc
312d5bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,12 +3,12 @@ the rules for authoring `.l2` API files. This | |
document expects some familiarity with *Lama2*. | ||
|
||
To quickly get started with *Lama2*, head over | ||
to [Examples](../tutorials/examples.md). | ||
to [Examples](../tutorials/examples.md). | ||
|
||
On the | ||
other hand, if you are a developer and wish to | ||
learn more about the formal grammar underlying | ||
*l2*, visit the [Grammar](../reference/grammar.md) | ||
*l2*, visit the [Grammar](../reference/grammar.md) | ||
section. | ||
|
||
### Comments start with `#` | ||
|
@@ -21,7 +21,6 @@ Fully supported: `GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH` | |
|
||
### JSON is the default submission type, but MULTIPART is supported too | ||
|
||
|
||
#### `varjson` is a simpler syntax to specify flat JSONs | ||
|
||
`varjson` values are defined as follows: | ||
|
@@ -42,10 +41,10 @@ The above results in a JSON submission of the form: | |
|
||
#### Nested JSON can simply be dumped at the end of the document | ||
|
||
The JSON recognition engine is quite lenient. It can deal with | ||
The JSON recognition engine is quite lenient. It can deal with | ||
minor errors in the format (such as having single quotes instead | ||
of double quotes, trailing garbage, or an extra comma after the | ||
last element in an array,). | ||
last element in an array,). | ||
|
||
``` | ||
POST | ||
|
@@ -57,8 +56,6 @@ https://httpbin.org/post | |
} | ||
``` | ||
|
||
|
||
|
||
#### MULTIPART allows both file uploads & the usual fields | ||
|
||
Example: | ||
|
@@ -75,24 +72,71 @@ file@./helloworld.jpg | |
|
||
The *file path is relative to the request file.* | ||
|
||
### Cookies are sent as headers | ||
### Cookies are sent as headers | ||
|
||
Cookies are specified in a `Cookie` header as follows: | ||
|
||
``` | ||
Cookie:'sessionid=foo;another-cookie=bar' | ||
``` | ||
|
||
### Environments variables/commands can be defined in `<requests_dir>/l2.env` | ||
### API variables can be defined in `apirequest.l2` | ||
|
||
L2 uses the variables declared inside the `.l2` file and makes the request | ||
|
||
By default, *l2* looks for a `l2.env` file in the same directory as the given | ||
request file directory. Example `l2.env`: | ||
Example `login.l2`: | ||
|
||
``` | ||
let REMOTE = "httpbin.org" | ||
let EMAIL = "[email protected]" | ||
|
||
--- | ||
|
||
POST | ||
${REMOTE}/login | ||
{ | ||
"email": "${EMAIL}", | ||
"password": "[email protected]" | ||
} | ||
``` | ||
|
||
Get [Source Files](https://github.com/HexmosTech/Lama2/tree/main/examples/0021_varjson_variable/0021_varjson_variable.l2) | ||
|
||
|
||
### API environment variables can be defined locally in `l2.env` | ||
|
||
`l2.env` is searched for, from the present directory and variables(local) are loaded from this file. | ||
|
||
Example `l2.env`: | ||
|
||
``` | ||
export PHOTO=`base64 aadhaarlarge.jpg` | ||
export AHOST="http://localhost:8000" | ||
``` | ||
|
||
Get [Source Files](https://github.com/HexmosTech/Lama2/tree/main/examples/0004_env_switch_root) | ||
|
||
### API environment variables can be defined at root using `l2config.env` | ||
`l2config.env` is searched for, from the present directory to all its ancestors (upto `/`) and | ||
variables(root) are loaded from this file. | ||
Example `l2config.env`: | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Screenshot needed to show project structure, and root. |
||
``` | ||
export PHOTO=`base64 aadhaarsmall.jpg` | ||
export AHOST="http://localhost:8001" | ||
``` | ||
|
||
Get [Source Files](https://github.com/HexmosTech/Lama2/tree/main/examples/0019_env_switch_global_root) | ||
|
||
### If `l2config.env`(root) variables are redeclared in `l2.env`(local) | ||
|
||
The local variable's value is taken into consideration regardless of both files reside in same directory | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Must show full example here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
Get [Source Files](https://github.com/HexmosTech/Lama2/tree/main/examples/0020_override_project_root_local) | ||
|
||
![Override of l2config.env with l2.env variable](image.png) | ||
|
||
|
||
#### The environment file can load results of commands | ||
|
||
Use the backtick notation `\`command\`` to place the results of | ||
|
@@ -126,4 +170,4 @@ variable `result` contains the response from previous stages. | |
|
||
For example, in the above case, `Javascript 2` can access the response from `L2 Request 1` through the `result` variable. | ||
|
||
Learn more about request chaining in [Examples](../tutorials/examples.md#chain-requests-using-javascript). | ||
Learn more about request chaining in [Examples](../tutorials/examples.md#chain-requests-using-javascript). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just check that with
verbose
mode as well - this works. I think we have a-v
and-vv
option IIRC.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes works.