IDE/Editor Support
Useful Options¶
The l2
command provides some helpful options for
extension developers. The options are:
--nocolor
or-n
disables colored output in httpie-go (in CLI);--output=<target.json
or-o
writes a structured JSON output to the target file (without colors). The following is the content structure:
{
"logs": ...,
"headers": ...,
"body": ...
}
logs
: String value. Contains ASCII-color-coded log output. Control the logging level through-v
optionheaders
: A string consisting ofHTTP header: Value
pairs separated by newline.body
: A string containing the HTTP response. Usually a JSON or HTML response.
Note
Right now, all the three values in the JSON are strings. In the future, we may transform the values further to provide a more parse-friendly structure.
The Command¶
Combining the above two options, we get:
l2 -n -o /tmp/lama2.json my_api.l2
The command mentioned above disables HTTPie colors,
writes the whole transaction to a structured JSON,
while also printing details into stdout
.
The extension author can simply read the file, and display the contents to users appropriately. For an example, see Lama2 for VSCode (also see Marketplace page).
Syntax Highlighting¶
The VSCode plugin implements a rudimentary syntax highlighting for .l2
files. We use Iro for syntax grammar generation. Find more details if interested.