This is a very basic fake API server. I use it to build the front-end of web applications, without the need for the backend to be ready.
It is an in-memory, non-persistent key-value store you can fill with PUT requests, where the request path is the key and the request body is the value.
Retrieve the saved value with a subsequent GET request at the same endpoint.
apimock will serve back the same Content-Type is has received. If no Content-Type header was sent with the PUT request, the DEFAULT_CONTENT_TYPE environment variable will be sent.
apimock is meant for prototyping. Please do NOT use it in production.
$ HOST=localhost:8800 apimock &
$ curl -X PUT -d '{"message": "This is not a pipe"}' localhost:8800/my/endpoint
> {"message": "This is not a pipe"}
$ curl -X GET localhost:8800/my/endpoint
> {"message": "This is not a pipe"}
$ curl -X DELETE localhost:8800/my/endpoint
$ curl -X GET localhost:8800/my/endpoint
$
Apimock will remember the Content-Type associated with every request. This behaviour can be modified with the environment variables:
DEFAULT_CONTENT_TYPE: When thePUTrequest doesn't bear aContent-Type, this one will be used. If not specified, this istext/plain.FORCED_CONTENT_TYPE: The specified string will be used asContent-Typeno matter what is transmitted with thePUTrequest.
docker run --name apimock -p 8800:8800 -d pierreprinetti/apimock:latest
It currently supports:
- CORS headers (responses always bear
Allow-Origin: *and a bunch of authorized headers and methods) -
OPTIONS -
PUT -
GET -
DELETE -
Content-Typeheader
What it might support in the future:
-
POSTto an endpoint with fake ID generator (e.g.POSTtoexample.com/itemswould result in the storage of the element inexample.com/items/1