feat(http): more comprehensive highlights

This commit is contained in:
Riley Bruins 2024-11-02 19:55:35 -07:00 committed by Christian Clason
parent eff88f4e8b
commit 2d5c122af9
3 changed files with 68 additions and 2 deletions

View file

@ -5,9 +5,17 @@
(header
name: (_) @constant)
(header
value: (_) @string)
; Variables
(identifier) @variable
(variable_declaration
name: (identifier) @variable)
"@" @character.special)
(variable_declaration
(value) @string)
; Operators
(comment
@ -25,7 +33,7 @@
(request
url: (_) @string.special.url)
(http_version) @constant
(http_version) @string.special
; Response
(status_code) @number
@ -36,8 +44,12 @@
[
"{{"
"}}"
"{%"
"%}"
] @punctuation.bracket
">" @punctuation.special
(header
":" @punctuation.delimiter)

View file

@ -0,0 +1,33 @@
@ENDPOINT=http://localhost:8080/api
# <- @character.special
# ^^^^^^^ @variable
# ^ @operator
# ^^^^^^^^^^^^^^^^^^^^^^^^^ @string
### GET USERS
GET {{ENDPOINT}}/users HTTP/1.1
# ^^ @punctuation.bracket
# ^^^^^^^^ @variable
# ^^ @punctuation.bracket
# ^^^^^^ @string.special.url
# ^^^^^^^^ @string.special
### GET USERS by Offset
GET {{ENDPOINT}}/users?offset=30 HTTP/1.1
# <- @function.method
### POST login
POST {{ENDPOINT}}/auth/login HTTP/1.1
Content-Type: application/json
{
"username": "admin",
"password": "password"
}
### Log Out
POST {{ENDPOINT}}/auth/logout HTTP/1.1
Content-Type: application/json
# ^^^^^^^^^^ @constant
# ^ @punctuation.delimiter
# vim: ft=http

View file

@ -0,0 +1,21 @@
### post-request script
GET https://jsonplaceholder.typicode.com/posts/3
# @lang=lua
> {%
local body = vim.json.decode(response.body)
client.global.set("postId", body.id)
-- ^ @lua
%}
### run request with variable
GET https://jsonplaceholder.typicode.com/posts/{{postId}}
> {%
client.global.set("auth_token", response.body.jwt);
// ^ @javascript
%}
### vim: ft=http