November 29, 2018
postman, insomnia, paw중
가장 최근에 사용한 paw 정말 좋았다.
다만 5만원정도 맥에서만 지원 하는 프로그램이다.
30일 무료로 사용해보았는데 구입하고 싶은 마음이 마구 들었다.
그러다가 대체할 만한 것이 있을까 보니
intellij 에서 지원을 한다.
(돈 굳었당 ~ 굳은돈으로 오즈모포켓을ㅠㅠ )
확장자는 .http
실행방법은 line 왼쪽에 ▶를누르면 된다.
방법
파일생성
사용 예제는
아래처럼 생긴 아이콘을 누르면 예제가 나온다.
requests : get, auth, post
responses: test
get-requets.http
### Get request with a header GET https://httpbin.org/ip Accept: application/json
GET https://httpbin.org/get?show\_env=1 Accept: application/json
GET {{host}}/get?show_env={{show_env}} Accept: application/json
GET http://httpbin.org/status/301
auth-requtes.http
### Basic authorization. GET https://httpbin.org/basic-auth/user/passwd Authorization: Basic user passwd
GET https://httpbin.org/basic-auth/user/passwd Authorization: Basic {{username}} {{password}}
GET https://httpbin.org/digest-auth/realm/user/passwd Authorization: Digest user passwd
GET https://httpbin.org/digest-auth/realm/user/passwd Authorization: Digest {{username}} {{password}}
POST https://httpbin.org/post Content-Type: application/json
{ “token”: “my-secret-token” }
{% client.global.set(“auth_token”, response.body.json.token); %}
GET https://httpbin.org/headers Authorization: Bearer {{auth_token}}
post-requtes.http
### Send POST request with json body POST https://httpbin.org/post Content-Type: application/json
{ “id”: 999, “value”: “content” }
POST https://httpbin.org/post Content-Type: application/x-www-form-urlencoded
id=999&value=content
POST https://httpbin.org/post Content-Type: multipart/form-data; boundary=WebAppBoundary
—WebAppBoundary Content-Disposition: form-data; name=“element-name” Content-Type: text/plain
Name —WebAppBoundary Content-Disposition: form-data; name=“data”; filename=“data.json” Content-Type: application/json
< ./request-form-data.json —WebAppBoundary—
test-responses.http
### Successful test: check response status is 200 GET https://httpbin.org/status/200
{% client.test(“Request executed successfully”, function() { client.assert(response.status === 200, “Response status is not 200”); }); %}
GET https://httpbin.org/status/404
{% client.test(“Request executed successfully”, function() { client.assert(response.status === 200, “Response status is not 200”); }); %}
{% client.test(“Request executed successfully”, function() { client.assert(response.status === 200, “Response status is not 200”); });
client.test(“Response content-type is json”, function() { var type = response.contentType.mimeType; client.assert(type === “application/json”, “Expected ‘application/json’ but received ’” + type + ”’”); }); %}
{% client.test(“Headers option exists”, function() { client.assert(response.body.hasOwnProperty(“headers”), “Cannot find ‘headers’ option in response”); }); %}
관련 페이지
https://www.jetbrains.com/help/idea/http-client-in-product-code-editor.html
https://www.jetbrains.com/help/idea/testing-restful-web-services.html