h2non / gock

HTTP traffic mocking and testing made easy in Go ༼ʘ̚ل͜ʘ̚༽

Home Page:https://pkg.go.dev/github.com/h2non/gock

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Configuration request and response from JSON file

patsevanton opened this issue · comments

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
commented

Not natively, but you can easily parse a JSON input and map its definitions into proper gock instances. As this feature is not a native responsibility of gock, there are no plans to support it.