Git Product home page Git Product logo

stubber's Introduction

Starting the proxy

After you have installed NodeJS and ran npm install:

node bin/index --target=http://targethost.com --port=5001 (optional)

Where port is the port the proxy server will listen on and target is the server to which calls that are not mocked will be proxied. The port defaults to 5001.

   

Swagger

It is also possible to supply a separate swaggerHost in case you want the Swagger UI's "try-it-out" feature to work and localhost is not the address at which the server will be available publicly - for instance if your application is deployed on AWS. If you don't supply this parameter, localhost is assumed as a host and the port is either 5001 or the value of port.

node bin/index --target=http://targethost.com --port=5001 --swaggerHost=http://www.anotherhost.com:5002/somePath

The logs will report where the Swagger endpoint can be reached.

   

Setting a mock response

Method: PUT

/proxy/setMockResponse

Content body
 {
     "url": "/the/url/to/override",
     "statusCode": 500,
     "body": {
         "sample": "response"
     },
     "responseHeaders": {
         "key": "value",
     },
     delay : 2000,
     times: 5
 }

Setting a delay and/or a number of times are both optional! If no delay is given, it defaults to 0. If no number of times is given, it defaults to ∞.

   

Setting multiple delays

Method: POST

Set multiple delays at once. This will also affect existing mock responses!

/proxy/setDelays

Content body
 {
     "delays": [
         {
            "url": "/url",
            "delay": 2000
         },
         {
            "url": "/anotherurl",
            "delay": 5000
         }
      ]
 }

   

Clear a specific mock response

Method: DELETE

/proxy/clearMockResponse

Content body
 {
     "url": "/the/mock/url/to/remove"
 }

   

Clear all mock responses

/proxy/clearAllMockResponses

Method: DELETE

   

Clear all delays

Method: DELETE

Clear all delays. Does NOT clear any mock responses however!

/proxy/clearAllDelays

   

List proxied requests

Method: GET

Generate a list of all the requests that have been proxied through the proxy server and their responses, if any.

/proxy/listProxiedRequests?limit=50

Parameters:

limit The maximum number of requests, defaults to ∞.

   

List mock responses

Method: GET

Generate a map with all the mock responses that have been set for given URLs. The value in the map for a given key is the number of times that mock response was returned.

/proxy/listMockResponses

   

Clear the list of proxied calls

Method: DELETE

/proxy/clearProxiedCalls

stubber's People

Contributors

tickls avatar tombrtls avatar

Watchers

James Cloos avatar Ting Yang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.