jarcoal / httpmock

HTTP mocking for Golang
http://godoc.org/github.com/jarcoal/httpmock
MIT License
1.93k stars 103 forks source link

Configuration request and response from JSON file #81

Closed patsevanton closed 4 years ago

patsevanton commented 4 years ago

Hello. Can support import request and response from JSON file configuration? For example:

{
    "request": {
        "method": "GET",
        "url": "/test"
    },
    "response": {
        "status": 200,
        "body": "test 200 OK\n"
    }
}

Examples run

curl http://localhost/test
test 200 OK
maxatome commented 4 years ago

Hello, yes you can do it pretty easily.

If you ask for the integration of such feature in httpmock why not, but the format of the json file has to be more complete. Typically, one should import one route yes, but several routes too for one json file. Body request should be given too, and so its content-type. Content-type is missing from the response too. Do not forget the possibility to set headers in response.

patsevanton commented 4 years ago

Hello.

I search, search and find utility https://github.com/brianmoran/mockify Thank you.