Skip to content

kevinjqiu/imposter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 

Repository files navigation

    ____                           __           
   /  _/___ ___  ____  ____  _____/ /____  _____
   / // __ `__ \/ __ \/ __ \/ ___/ __/ _ \/ ___/
 _/ // / / / / / /_/ / /_/ (__  ) /_/  __/ /    
/___/_/ /_/ /_/ .___/\____/____/\__/\___/_/     
             /_/                                

A server that pretends to be another service.

Start the Server

Start the server:

$ go run imposter.go
[martini] listening on :3000

Create a Preset

curl -XPOST -H"Content-Type:application/json" http://localhost:3000/p -d'{
    "matcher": {
       "method": "POST",
       "endpoint": "/foo",
       "headers": {
         "Accept": "application/json"
       },
       "body": "{}"
     },
     "response": {
       "status_code": 400,
       "headers": {
         "Content-Type": "application/json"
       },
       "body": "{\"message\": \"nope\"}"
      }
    }'

This creates a preset for the endpoint /m/foo. When a request to localhost:3000/m/foo with the header Accept: application/json and request body {}, the response given will be 400 Bad Request with the header Content-Type: application/json and the body {"message": "nope"}.

About

A server that pretends to be another service.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages