MCPcopy Index your code
hub / github.com/bayne/dot-http

github.com/bayne/dot-http @v0.2.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.2.0 ↗ · + Follow
96 symbols 195 edges 15 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

dot-http

Verify build gitmoji Powered by Rust

dot-http is a text-based scriptable HTTP client. It is a simple language that resembles the actual HTTP protocol but with just a smidgen of magic to make it more practical for someone who builds and tests APIs.

demo

Installation

Script

Enter the following in a command prompt:

```text,no_run curl -LSfs https://japaric.github.io/trust/install.sh | sh -s -- --git bayne/dot-http


### Binary releases

The easiest way for most users is simply to download the prebuilt binaries.
You can find binaries for various platforms on the
[release](https://github.com/bayne/dot-http/releases) page.

### Cargo

First, install [cargo](https://rustup.rs/). Then:

```bash,no_run
$ cargo install dot-http

You will need to use the stable release for this to work; if in doubt run

```bash,no_run rustup run stable cargo install dot-http


## Usage

See `dot-http --help` for usage.

### Vim

See this [plugin](https://github.com/bayne/vim-dot-http) to use dot-http within vim.

### The request

The request format is intended to resemble HTTP as close as possible. HTTP was initially designed to be human-readable and simple, so why not use that?

**simple.http**
```text,no_run
GET http://httpbin.org
Accept: */*

Executing that script just prints the response to stdout: ```text,no_run $ dot-http simple.http GET http://httpbin.org/get

HTTP/1.1 200 OK access-control-allow-credentials: true access-control-allow-origin: * content-type: application/json date: Sat, 18 Jan 2020 20:48:50 GMT referrer-policy: no-referrer-when-downgrade server: nginx x-content-type-options: nosniff x-frame-options: DENY x-xss-protection: 1; mode=block content-length: 170 connection: keep-alive

{ "args": {}, "headers": { "Accept": "/", "Host": "httpbin.org" }, "url": "https://httpbin.org/get" }


### Variables

Use variables to build the scripts dynamically, either pulling data from your environment file or from a previous request's response handler.

**simple_with_variables.http**
```text,no_run
POST http://httpbin.org/post
Accept: */*
X-Auth-Token: {{token}}

{
    "id": {{env_id}}
}

http-client.env.json ```text,no_run { "dev": { "env_id": 42, "token": "SuperSecretToken" } }


Note that the variables are replaced by their values
```text,no_run
$ dot-http simple_with_variables.http
POST http://httpbin.org/post

HTTP/1.1 200 OK
access-control-allow-credentials: true
access-control-allow-origin: *
content-type: application/json
date: Sat, 18 Jan 2020 20:55:24 GMT
referrer-policy: no-referrer-when-downgrade
server: nginx
x-content-type-options: nosniff
x-frame-options: DENY
x-xss-protection: 1; mode=block
content-length: 342
connection: keep-alive

{
  "args": {},
  "data": "{\r\n    \"id\": 42\r\n}",
  "files": {},
  "form": {},
  "headers": {
    "Accept": "*/*",
    "Content-Length": "18",
    "Host": "httpbin.org",
    "X-Auth-Token": "SuperSecretToken"
  },
  "json": {
    "id": 42
  },
  "url": "https://httpbin.org/post"
}

Environment file

Use an environment file to control what initial values variables have

http-client.env.json ```text,no_run { "dev": { "host": localhost, "token": "SuperSecretToken" }, "prod": { "host": example.com, "token": "ProductionToken" } }


**env_demo.http**
```text,no_run
GET http://{{host}}
X-Auth-Token: {{token}}

Specifying different environments when invoking the command results in different values for the variables in the script

```text,no_run $ dot-http -e dev env_demo.http GET http://localhost X-Auth-Token: SuperSecretToken

$ dot-http -e prod env_demo.htp GET http://example.com X-Auth-Token: ProductionToken


### Response handler

Use previous requests to populate some of the data in future requests

**response_handler.http**
```text,no_run
POST http://httpbin.org/post
Content-Type: application/json

{
    "token": "sometoken",
    "id": 237
}

> {%
   client.global.set('auth_token', response.body.json.token);
   client.global.set('some_id', response.body.json.id);
%}

###

PUT http://httpbin.org/put
X-Auth-Token: {{auth_token}}

{
    "id": {{some_id}}
}

Data from a previous request

```text,no_run $ dot-http test.http POST http://httpbin.org/post

HTTP/1.1 200 OK access-control-allow-credentials: true access-control-allow-origin: * content-type: application/json date: Sat, 18 Jan 2020 21:01:59 GMT referrer-policy: no-referrer-when-downgrade server: nginx x-content-type-options: nosniff x-frame-options: DENY x-xss-protection: 1; mode=block content-length: 404 connection: keep-alive

{ "args": {}, "data": "{\r\n \"token\": \"sometoken\",\r\n \"id\": 237\r\n}", "files": {}, "form": {}, "headers": { "Accept": "/", "Content-Length": "46", "Content-Type": "application/json", "Host": "httpbin.org" }, "json": { "id": 237, "token": "sometoken" }, "url": "https://httpbin.org/post" }


Can populate data in a future request

```text,no_run
$ dot-http -l 16 test.http
PUT http://httpbin.org/put

HTTP/1.1 200 OK
access-control-allow-credentials: true
access-control-allow-origin: *
content-type: application/json
date: Sat, 18 Jan 2020 21:02:28 GMT
referrer-policy: no-referrer-when-downgrade
server: nginx
x-content-type-options: nosniff
x-frame-options: DENY
x-xss-protection: 1; mode=block
content-length: 336
connection: keep-alive

{
  "args": {},
  "data": "{\r\n    \"id\": 237\r\n}",
  "files": {},
  "form": {},
  "headers": {
    "Accept": "*/*",
    "Content-Length": "19",
    "Host": "httpbin.org",
    "X-Auth-Token": "sometoken"
  },
  "json": {
    "id": 237
  },
  "url": "https://httpbin.org/put"
}

Contributing

Contributions and suggestions are very welcome!

Please create an issue before submitting a PR, PRs will only be accepted if they reference an existing issue. If you have a suggested change please create an issue first so that we can discuss it.

License

Apache License 2.0

Extension points exported contracts — how you extend this code

FromPair (Interface)
(no doc) [8 implementers]
src/parser/mod.rs
Processable (Interface)
(no doc) [4 implementers]
src/script_engine/mod.rs
ResponseHandler (Interface)
(no doc) [1 implementers]
src/response_handler/mod.rs
ToSelection (Interface)
(no doc) [2 implementers]
src/parser/mod.rs
ScriptEngine (Interface)
(no doc) [1 implementers]
src/script_engine/mod.rs
Outputter (Interface)
(no doc) [1 implementers]
src/response_handler/mod.rs

Core symbols most depended-on inside this repo

parse
called by 11
src/script_engine/boa.rs
parse
called by 11
src/parser/mod.rs
invalid_pair
called by 8
src/parser/mod.rs
to_selection
called by 8
src/parser/mod.rs
execute
called by 7
src/controller/mod.rs
execute
called by 4
src/script_engine/boa.rs
initialize
called by 4
src/script_engine/boa.rs
process
called by 4
src/script_engine/mod.rs

Shape

Function 33
Method 27
Class 24
Enum 6
Interface 6

Languages

Rust100%

Modules by API surface

src/model.rs16 symbols
src/response_handler/mod.rs14 symbols
src/script_engine/boa.rs12 symbols
src/parser/tests.rs11 symbols
src/script_engine/mod.rs9 symbols
src/parser/mod.rs9 symbols
src/controller/mod.rs7 symbols
src/script_engine/tests.rs5 symbols
src/http_client/mod.rs4 symbols
src/response_handler/tests.rs3 symbols
src/main.rs2 symbols
src/controller/tests.rs2 symbols

For agents

$ claude mcp add dot-http \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact