HTTPlex is an Elixir-based web service that provides a simple HTTP request and response service. It is inspired from httpbin and helps developers test and debug HTTP requests.
The project is built using Elixir and the Phoenix framework. It defines a controller (HTTPlexWeb.APIController
) that handles various HTTP endpoints:
HTTP Methods:
index/2
: Welcome messageget/2
,post/2
,put/2
,patch/2
,delete/2
: Return request info for respective HTTP methodsanything/2
: Accepts and returns data for any HTTP method
Request Inspection:
ip/2
: Returns the client's IP addressuser_agent/2
: Returns the user-agent headerheaders/2
: Returns all request headers
Response Inspection:
response_headers/2
: Sets custom response headers
Auth:
basic_auth/2
,hidden_basic_auth/2
: Test Basic Authentication (hidden version doesn't send WWW-Authenticate header)bearer/2
: Tests Bearer Token Authenticationdigest_auth/2
: Tests Digest Authentication
Status codes:
status/2
: Returns response with specified status code
Request formats:
forms_post/2
: Handles form data submission
Response formats:
html_response/2
: Returns an HTML responsejson_response/2
: Returns a JSON responsexml/2
: Returns an XML responseimage/2
: Returns an image in specified format
Redirects:
absolute_redirect/2
: Performs absolute redirectsredirect_to/2
: Redirects to specified URLredirectx/2
: Performs multiple redirectsrelative_redirect/2
: Performs relative redirects
Dynamic data:
uuid/2
: Generates and returns a UUIDrandom_bytes/2
: Returns random bytesdeny/2
: Simulates denied access by robots.txtrobots_txt/2
: Returns a sample robots.txt filedelay/2
: Delays the response for specified secondsdrip/2
: Drips data over a durationlinks/2
: Returns page containing n linksrange/2
: Streams n bytes with Accept-Ranges and Content-Range headersstream_bytes/2
: Streams n bytes of datastream_json/2
: Streams JSON data
Cookies:
get_cookies/2
: Returns all cookies sent with the requestset_cookies/2
,set_cookie/2
: Set multiple or a single cookiedelete_cookies/2
: Deletes specified cookies
Encoding:
brotli/2
: Returns Brotli-encoded datadeflate/2
: Returns Deflate-encoded datagzip/2
: Returns GZip-encoded dataencoding_utf8/2
: Returns UTF-8 encoded text
Caching:
cache/2
: Tests caching headerscache_control/2
: Sets Cache-Control header with specified max-ageetag/2
: Tests ETag functionality
Each function or group of functions corresponds to different features or test scenarios for HTTP requests and responses.
To use HTTPlex, send HTTP requests to the appropriate endpoints. The service will respond with JSON data (in most cases) containing the requested information or performing the specified action.
For example:
GET /ip
will return your IP address.POST /post
with some data will echo back information about your POST request.GET /status/404
will respond with a 404 status code.
This service is particularly useful for testing HTTP clients, debugging web applications, and understanding how different types of HTTP requests are structured and processed.
To start your Phoenix server:
- Run
mix setup
to install and setup dependencies - Start Phoenix endpoint with
mix phx.server
or inside IEx withiex -S mix phx.server
Now you can visit localhost:4000
from your browser.
Ready to run in production? Please check Phoenix deployment guides.
The theme is available as open source under the terms of the MIT License.
Bug reports and pull requests are welcome on GitHub at https://github.com/abhinavs/httplex.
If you like HTTPlex, do check out my other projects
- soopr - a tool that supports you in content marketing
- ping - monitor your websites's uptime
- annexr - chat based search for your website.
- apicagent - a FREE API that extracts device details from user-agent string
✨⚡You can read more about me on my blog or follow me on Twitter - @abhinav