Visual Studio Code Rest client extensions

Visual Studio Code Rest client extensions , 是我用開 Visual Studio Code 寫 code 時的一個好常用/adapt的feature。
” Rest client ” extensions其實就好似 Postman (一個chrome extension,用黎mock up去send HTTP request做testing)。
但佢就再簡化d,唔需要UI,而係用text就夠。
即係例如我隨便一個file入面有呢幾行字:

POST http://localhost:8080/items
Content-type: application/json

{
    "foo":"bar"
}

然後我select呢段字,禁ctrl+alt+r,就會mock up send左個request出去,再有一個tab show response (as text),如下:

HTTP/1.1 201 Created
Location: /items/35de0567-4299-43b2-866c-de0909aff39e
Content-Type: text/html; charset=utf-8
Content-Length: 20
ETag: W/"16-PckFq2NKgI0mytdvMX7e0Z0kBok"
Date: Sat, 01 Apr 2017 04:43:03 GMT
Connection: keep-alive

Create item success.

這個好處是,我能夠用一個text file就儲存好一堆mockup testing request。
需要更改時直接改內容就好。
測試時,也不用import/export到postman,並且不用離開IDE就能直接測試endpoint。

Leave a Reply

Your email address will not be published.