Syntax highlighting of 437b72d ~( httpie-jq)
# http [TOC] https://httpie.org/ [cheatsheets](https://devhints.io/httpie) ```bash # Custom [HTTP method], [HTTP headers] and [JSON] data: http PUT example.org X-API-Token:123 name=John # POST method with json http :3000/api/v1/widget/users foo=bar user:='{"email": "user@example.com", "password": "1qazxdr5"}' # submitting forms http -f POST example.org hello=World # See the request that is being sent using one of the output options http -v yandex.ru # Upload a file using [redirected input](https://httpie.org/doc#redirected-input): http example.org < file.json # Download a file and save it via [redirected output](https://httpie.org/doc#redirected-output): http example.org/file > file ``` ## Auth ### JWT Вариант 1 ```bash http http://httpbin.org/bearer "Authorization: Bearer secrettoken" ``` Вариант 2 https://httpie.io/docs#auth-plugins [httpie-jwt-auth](https://github.com/teracyhq/httpie-jwt-auth) ```bash pip install -U httpie-jwt-auth export JWT_AUTH_TOKEN=secret http teracy.com --auth-type=jwt -v ``` # jq https://stedolan.github.io/jq/ ```bash # --- первый элемент массив в поле data http :8001/services | jq .data[0] # --- все поля `name` в массиве data http :8001/services | jq .data[].name ``` Выход со кодом ошибки ```bash http $LINT_URL PRIVATE-TOKEN:$TOKEN content=@$TARGET_FILE | jq -e '.status == "valid"' echo $? 0 http $LINT_URL PRIVATE-TOKEN:$TOKEN content=@$TARGET_FILE | jq -e '.status == "valid1"' echo $? 1 ``` Поле с точкой ```bash # --- jq -r уберет кавычки у значения jmxremote.access k get secret jmxremote -o json | jq '.data."jmxremote.access"' ```
