Skip to content

Commit cd6815d

Browse files
authored
feat: allow skipping SSL verification, closes #46 (#50)
1 parent 4155307 commit cd6815d

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

README.md

+14-6
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,12 @@ use {
5454
'NTBBloodbath/rest.nvim',
5555
requires = { 'nvim-lua/plenary.nvim' },
5656
config = function()
57-
require('rest-nvim').setup({
58-
result_split_horizontal = false,
59-
})
57+
require("rest-nvim").setup({
58+
-- Open request results in a horizontal split
59+
result_split_horizontal = false,
60+
-- Skip SSL verification, useful for unknown certificates
61+
skip_ssl_verification = false,
62+
})
6063
end
6164
}
6265
```
@@ -66,12 +69,17 @@ use {
6669
By default `rest.nvim` does not have any key mappings so you will not have
6770
conflicts with any of your existing ones.
6871

69-
To run `rest.nvim` you should map the `<Plug>RestNvim` and `<Plug>RestNvimPreview` commands.
72+
To run `rest.nvim` you should map the following commands:
73+
- `<Plug>RestNvim`, run the request under the cursor
74+
- `<Plug>RestNvimPreview`, preview the request cURL command
75+
- `<Plug>RestNvimLast`, re-run the last request
7076

7177
## Settings
7278

73-
* `result_split_horizontal` opens result on a horizontal split (default opens
74-
on vertical)
79+
- `result_split_horizontal` opens result on a horizontal split (default opens
80+
on vertical)
81+
- `skip_ssl_verification` passes the `-k` flag to cURL in order to skip SSL verification,
82+
useful when using unknown certificates
7583

7684
## Usage
7785

doc/rest-nvim.txt

+10
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ FEATURES *rest-nvim-features*
4848
===============================================================================
4949
QUICK START *rest-nvim-quick-start*
5050

51+
After installing `rest.nvim` you will need to configure it using a `setup`
52+
function, it looks like this by default:
53+
54+
`require("rest-nvim").setup({`
55+
` -- Open request results in a horizontal split`
56+
` result_split_horizontal = false,`
57+
` -- Skip SSL verification, useful for unknown certificates`
58+
` skip_ssl_verification = false,`
59+
`})`
60+
5161
In this section we will be using `https://reqres.in/` for requests.
5262

5363
Let's say we want to create a new user and send our body as a JSON, so we

lua/rest-nvim/config.lua

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ local M = {}
22

33
local config = {
44
result_split_horizontal = false,
5+
skip_ssl_verification = false,
56
}
67

78
--- Get a configuration value

lua/rest-nvim/init.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,9 @@ rest.run = function(verbose)
319319
url = parsed_url.url,
320320
headers = headers,
321321
-- accept = accept,
322+
raw = config.skip_ssl_verification and { "-k" } or nil,
322323
body = body, -- the request body (string/filepath/table)
323-
dry_run = verbose and verbose or false,
324+
dry_run = verbose or false,
324325
})
325326

326327
if not success_req then

0 commit comments

Comments
 (0)