We can't find the internet
Something went wrong!
Echo... echo
- Created: 12/01/2015
- Last updated: 13/12/2024
Recently I have been developing a javascript heavy application whos purpose is to present data provided by a REST API which does not yet exist.
To help with this and to enable me to demonstrate the app working, I spent a couple of hours putting together a service which will respond to my http requests in whatever way I like. Check it out
I have been finding this app rather useful, so I thought I would share.
By default echo will respond successfully with an empty response body, but by setting request params (as json or url params), you can control its response status, body and headers. There are examples on the apps home page to get you started.
It is a sinatra based app, and when putting it together, I took the chance to try out minitest over rspec which is my usual choice when testing ruby. I wanted to use minitest as it is a lighter, and should run faster. It was interesting trying another solution to the same problem, it worked great, and ran impressively fast. I will be using rspec again to test my next ruby project, as it is what I am used to and therefore I can write tests quickly and focus on the project I am working on. But will definitely make a point of trying out minitest again soon.
The other interesting part was setting up cors headers in sinatra which I have not needed to do before. This was pleasingly simple to do, and can be seen on github
The source is on github, and the app itself is hosted here: http://echo.nathansplace.co.uk. It comes with a docker file so you can easily run your own version locally :)