{"id":15288788,"url":"https://github.com/evermeshsolutions/putsreq","last_synced_at":"2026-03-07T17:06:45.473Z","repository":{"id":16070039,"uuid":"18814419","full_name":"EvermeshSolutions/putsreq","owner":"EvermeshSolutions","description":"PutsReq lets you record HTTP requests and fake responses like no other tool available","archived":false,"fork":false,"pushed_at":"2020-07-28T14:21:36.000Z","size":1714,"stargazers_count":269,"open_issues_count":4,"forks_count":47,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-27T01:11:15.245Z","etag":null,"topics":["putsreq","rails","ruby"],"latest_commit_sha":null,"homepage":"https://putsreq.com","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EvermeshSolutions.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-04-15T20:18:01.000Z","updated_at":"2024-10-15T12:28:20.000Z","dependencies_parsed_at":"2022-08-31T11:52:02.078Z","dependency_job_id":null,"html_url":"https://github.com/EvermeshSolutions/putsreq","commit_stats":null,"previous_names":["phstc/putsreq"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvermeshSolutions%2Fputsreq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvermeshSolutions%2Fputsreq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvermeshSolutions%2Fputsreq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvermeshSolutions%2Fputsreq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EvermeshSolutions","download_url":"https://codeload.github.com/EvermeshSolutions/putsreq/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248693904,"owners_count":21146885,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["putsreq","rails","ruby"],"created_at":"2024-09-30T15:53:10.679Z","updated_at":"2026-03-07T17:06:45.431Z","avatar_url":"https://github.com/EvermeshSolutions.png","language":null,"readme":"[![Build Status](https://travis-ci.org/phstc/putsreq.svg)](https://travis-ci.org/phstc/putsreq)\n[![Code Climate](https://codeclimate.com/github/phstc/putsreq/badges/gpa.svg)](https://codeclimate.com/github/phstc/putsreq)\n[![Test Coverage](https://codeclimate.com/github/phstc/putsreq/badges/coverage.svg)](https://codeclimate.com/github/phstc/putsreq/coverage)\n\n**The PutsReq codebase will be private going forward. You can still integrate with the products as you could before and we've updated the support instructions below.**\n**Questions? Write us at support support@evermesh.com.**\n\n## PutsReq\n\nPutsReq lets you record HTTP requests and simulate responses like no other tool available. [Try it now](http://putsreq.com)!\n\nCheck this post: [Play Rock-paper-scissors with Slack and PutsReq](http://www.pablocantero.com/blog/2014/10/12/play-rock-paper-scissors-with-slack-and-putsreq/) for some other examples.\n\n### Getting Started\n\n### Response Builder\n\nThe Response Builder is the place where you can create your responses using JavaScript V8.\n\nCheck the list below with the request attributes you can access to create your own responses:\n\n#### request\n\n```javascript\n// curl -X POST -H 'X-MyHeader: MyHeaderValue' -d 'name=Pablo' https://putsreq.com/\u003cYOUR-TOKEN\u003e\n\nrequest.request_method;\n// =\u003e POST\n\nrequest.body;\n// =\u003e name=Pablo\n\nrequest.params.name;\n// =\u003e Pablo\n\nrequest.headers[\"HTTP_X_MYHEADER\"];\n// =\u003e MyHeaderValue\n```\n\nParsing a JSON request:\n\n```javascript\n// curl -i -X POST -H 'Content-Type: application/json' -d '{\"message\":\"Hello World\"}' https://putsreq.com/\u003cYOUR-TOKEN\u003e\n\nvar parsedBody = JSON.parse(request.body);\n\nparsedBody.message;\n// =\u003e Hello World\n```\n\n#### response\n\n```javascript\nresponse.status = 200; // default value\nresponse.headers = {}; // default value\nresponse.body = \"ok\"; // default value\n```\n\nReturning a JSON response:\n\n```javascript\nresponse.headers[\"Content-Type\"] = \"application/json\";\n\nresponse.body = { message: \"Hello World\" };\n```\n\n#### forwardTo\n\nIf you only want to log your requests, you can use PutsReq just as a proxy for your requests.\n\n```javascript\nrequest.forwardTo = \"http://example.com/api\";\n```\n\nBut you can always modify requests before forwarding them.\n\n```javascript\n// add or change a header\nrequest.headers[\"X-MyNewHeader\"] = \"MyHeaderValue\";\n\nvar parsedBody = JSON.parse(request.body);\n\n// add or change a value\nparsedBody[\"my_new_key\"] = \"my new value\";\n\nrequest.body = parsedBody;\n\nrequest.forwardTo = \"http://example.com/api\";\n```\n\n### CLI\n\nDo want to test Webhook calls against your localhost? PutsReq makes it easy!\n\nYou can think of it, as a kind of [ngrok](http://ngrok.io), but instead of creating a tunnel to your localhost, PutsReq polls requests from `YOUR-PUTSREQ-TOKEN` and forwards to your localhost.\n\n```bash\ngem install putsreq\n\nputsreq forward --to http://localhost:3000 --token YOUR-TOKEN\n\nListening requests from YOUR-TOKEN\nForwarding to http://localhost:3000\nPress CTRL+c to terminate\n2016-12-21 20:49:54 -0200       POST    200\n```\n\n### Ajax\n\nPutsReq supports [CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing), so you can use it to test your Ajax calls.\n\n```html\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003ctitle\u003eYour Website\u003c/title\u003e\n    \u003cscript src=\"https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js\"\u003e\u003c/script\u003e\n    \u003cscript\u003e\n      // Sample PutsReq Response Builder\n      // https://putsreq.com/\u003cYOUR-TOKEN\u003e/inspect\n      // response.headers['Content-Type'] = 'application/json';\n      // response.body = { 'message': 'Hello World' };\n\n      // Sample Ajax call\n      $.get(\"https://putsreq.com/\u003cYOUR-TOKEN\u003e\", function (data) {\n        alert(data.message);\n        // =\u003e 'Hello World'\n      });\n    \u003c/script\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\u003c/body\u003e\n\u003c/html\u003e\n```\n\n### Sample Integration Tests\n\nhttps://github.com/phstc/putsreq_integration_sample\n\n### Steps to run PutsReq in development\n\nFor following the instructions below, you will need to install [Docker](https://www.docker.com/get-docker).\n\n```shell\ncd ~/workspace\n\ngit clone git@github.com:phstc/putsreq.git\n\ndocker-compose up -d\n\nopen http://localhost:3000\n\ndocker-compose logs --follow --tail=100 app\n```\n\n#### Running tests\n\n```shell\ndocker-compose run app bundle exec rspec\n```\n\n### Production\n\nIn production (Heroku), PutsReq runs on mLab sandbox, with a storage of 500 MB. For avoiding exceeding the capacity, the `requests` and `responses` collections must be converted into capped collections.\n\n```javascript\ndb.runCommand({ convertToCapped: \"requests\", size: 15000000 });\ndb.runCommand({ convertToCapped: \"responses\", size: 15000000 });\n```\n\n### Production setup through Docker\n\nThis walks you through a quick guideline in order to setup PutsReq on your own server through Docker and Docker Compose. Please read this section carefully and know what you are doing in order not to lose any data.\n\n#### Configuration\n\nThe `docker-compose.yml` file.\n\n```\nversion: '3.6'\nservices:\n  db:\n    image: mongo:3.6.17\n    tty: true\n    stdin_open: true\n    volumes:\n      - data:/data/db\n  redis:\n    image: redis:alpine\n  app:\n    image: daqzilla/putsreq\n    tty: true\n    stdin_open: true\n    command: /bin/sh -c \"rm -f /app/tmp/pids/server.pid \u0026\u0026 bundle exec rails server -p 3000 -b '0.0.0.0'\"\n    ports:\n      - '5050:3000'\n    env_file:\n      - .env.docker\n    depends_on:\n      - db\n      - redis\nvolumes:\n  data:\n    external:\n      name: putsreq_mongodb\n```\n\nThe `.env.docker` file.\n\n```\nRAILS_ENV=production\nMONGOLAB_URI=mongodb://db\nREDIS_URL=redis://redis\nDEVISE_SECRET_KEY=123\nSECRET_TOKEN=123\n```\n\n#### External Docker volume FTW\n\nThe external volume referenced within the `docker-compose.yml` file has been created by invoking:\n\n```\ndocker volume create --name=putsreq_mongodb\n```\n\nThe rationale for creating the external volume is https://stackoverflow.com/questions/53870416/data-does-not-persist-to-host-volume-with-docker-compose-yml-for-mongodb. Otherwise, data stored in MongoDB might get lost as already observed by @ddavtian within #51.\n\n#### Reverse-proxy configuration for Nginx\n\nLast but not least, this Nginx snippet has been used for configuring a HTTP reverse proxy to the PutsReq instance:\n\n```\nserver {\n    listen 443 ssl;\n    listen [::]:443 ssl;\n\n    server_name putsreq.example.org;\n\n    #include snippets/snakeoil.conf;\n    include snippets/ssl/putsreq.example.org;\n\n    proxy_buffering off;\n\n    location / {\n        proxy_set_header        Host               $http_host;\n        proxy_set_header        X-Real-IP          $remote_addr;\n        proxy_set_header        X-Forwarded-For    $proxy_add_x_forwarded_for;\n        proxy_set_header        X-Forwarded-Proto  $scheme;\n        proxy_pass              http://localhost:5050/;\n    }\n\n}\n```\n\n#### Ready-made Docker image on Docker Hub\n\nThe Docker image on https://hub.docker.com/r/daqzilla/putsreq has been amended using the patch [putsreq-production.patch.txt](https://github.com/phstc/putsreq/files/4554757/putsreq-production.patch.txt).\n\nIt is not the most performant way to compile and serve assets like that on a production instance, precompiling and serving them from a webserver in a static manner should be preferred.\n\n#### Outlook\n\nImproving this quick \u0026 dirty production-configuration would be nice, pull requests are welcome. In order to make that possible,\na) the image on Docker Hub should be republished without the amendments but with precompiled assets and\nb) the Nginx snippet should be adjusted to serve the assets in a static manner.\n\nThe Docker images published to https://hub.docker.com/u/daqzilla have been built like that:\n\n```\n# Acquire sources\ngit clone https://github.com/phstc/putsreq\ncd putsreq\n\n# Apply patch\nwget https://github.com/phstc/putsreq/files/4554757/putsreq-production.patch.txt\npatch -p1 \u003c putsreq-production.patch.txt\n\n# Build\ndocker build --tag daqzilla/putsreq:latest .\n\n# Upload\ndocker login\ndocker push daqzilla/putsreq\n```\n\n### License\n\nPlease see [LICENSE](https://github.com/phstc/putsreq/blob/master/LICENSE) for licensing details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevermeshsolutions%2Fputsreq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevermeshsolutions%2Fputsreq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevermeshsolutions%2Fputsreq/lists"}