Introducing Unix Domain Socket Support

One of the headlining features of Insomnia 5.4.0 is support for UNIX Domain Sockets – a mechanism typically used for communication between processes running on the same host operating system. This post gives a brief introduction on connecting to a socket within Insomnia.

In order for Insomnia to distinguish socket requests, a slightly different URL syntax is required. The following syntax was borrowed from the popular NodeJS request library.

# Syntax for UNIX domain sockets
http://unix:$SOCKET:$PATH

Note: This feature provides same functionality as using the --unix-socket FILE flag with curl.

Example Using Docker Engine API

To demonstrate socket support, we'll issue a request to the /images endpoint that is exposed by the Docker Engine's socket API. Using the following URL in Insomnia will list the available Docker images on the host machine.

# Sample URL to communicate with Docker socket
http://unix:/var/run/docker.sock:/v1.24/images/json

This URL is specifying the path to the socket (/var/run/docker.sock) and the API endpoint path (/v1.24/images/json) using the previously mentioned URL syntax. Here's what it looks like within Insomnia.

Domain Sockets Example

Since the Docker socket communicates using HTTP and JSON, it looks indistinguishable from regular TCP/IP-based HTTP requests being made over the network.

And that's it! I can't wait to hear what you think!


Need a better way to test APIs?