Using DataShim To Serve Static Data

Itamar Nabriski
Dec 24, 2017 · 3 min read

Serving static data with DataShim is almost completely straight-forward. The only tricky part is using the $file variable in the Shim script.

Let’s assume we are building an app that takes its JSON configuration from a remote server. The server is not there yet, but we still want to develop the app independently, against a typical server configuration obtained from a remote endpoint.

This will be our test configuration:


We create the Shim in the DataShim Editor:

We first go to the Parameters tab and input our test JSON data in the File field:

Then we go back to the Script tab and change the script to echo “$file”:

Now we can click the Run button and see the result in the Output field:

To validate our data, we can pipe the content of $file to the jq program and also get pretty printing for free:

Of course, we still need to turn this into a URL we can use in our app. In order to do this, we need to Save our Shim. Then we get a few more options, one being the Shim URL. We can take this URL and use it in our app.


Using curl on the Shim URL, we can see our data is returned:

curl -s
“ttl”: 3000,
“retries”: 2,
“maxThreads”: 5

If we look at the headers as well, we see the ‘content type’ is derived correctly as JSON. Also, the URL has CORS support out of the box and can be called with either http or https:

curl -vs
* Trying…
* Connected to ( port 443 (#0)
... SSL stuff ...
> GET /interdenominational-decantations HTTP/1.1
> Host:
> User-Agent: curl/7.56.1
> Accept: */*
< HTTP/1.1 200 OK
< Server: nginx/1.12.1
< Date: Sun, 24 Dec 2017 15:12:24 GMT
< Content-Type: application/json; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< X-Powered-By: Express
< Access-Control-Allow-Origin: *
“ttl”: 3000,
“retries”: 2,
“maxThreads”: 5

Once the real server is up, we simply swap the Shim URL with the real server URL.


Itamar Nabriski

Written by



How To Use DataShim

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade