Nothing Special   »   [go: up one dir, main page]

Skip to content

Latest commit

 

History

History
43 lines (36 loc) · 1.1 KB

README.md

File metadata and controls

43 lines (36 loc) · 1.1 KB

Mock GO

This is very simple golang http mock server based on gorilla/mux.

Install

go get -u github.com/rukavina/mockgo

Configuration

It's expected to have config.json in the same folder as executable. Eg:

{
    "description": "Test mock definitions",
    "endpoints":[
        {
            "request":{
                "path": "/hello"
            },
            "response":{
                "bodyFileName": "responses/hello.json"
            } 
        },
        {
            "request":{
                "path": "/hello2"
            },
            "response":{
                "body": "{\"text\": \"Hello\",\"name\": \"World\"}",
                "headers": {
                    "Content-Type":"application/json"
                }
            } 
        }        
    ]
}

The request.path defines the url at which the mock serves responses. It's gorilla mux'es path definition. Request routing can be further specified via request fields like: scheme,host,method,query,headers.

Response data can be either defined inline via body or as external file in bodyFileName.