Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ jobs:
target: x86_64-unknown-linux-gnu
archive: tar.gz

- name: windows
os: windows-latest
target: x86_64-pc-windows-msvc
archive: zip

steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -53,11 +58,19 @@ jobs:
TARGET="${{ matrix.target }}"
VERSION="${GITHUB_REF_NAME}"

cp target/$TARGET/release/$BIN_NAME .
if [[ "$TARGET" == *-windows-* ]]; then
BIN_NAME="reqsh.exe"
fi

ARCHIVE_NAME="${BIN_NAME}-${VERSION}-${TARGET}.tar.gz"
cp "target/$TARGET/release/$BIN_NAME" .

tar -czf dist/$ARCHIVE_NAME $BIN_NAME
if [[ "$TARGET" == *-windows-* ]]; then
ARCHIVE_NAME="${BIN_NAME}-${VERSION}-${TARGET}.zip"
7z a -tzip "dist/$ARCHIVE_NAME" "$BIN_NAME"
else
ARCHIVE_NAME="${BIN_NAME}-${VERSION}-${TARGET}.tar.gz"
tar -czf "dist/$ARCHIVE_NAME" "$BIN_NAME"
fi

- name: Upload Release Asset
uses: softprops/action-gh-release@v2
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 0.1.3 (2026-06-09)

- Response time displayed with each request
- Windows binary support (x86_64-pc-windows-msvc)
- Absolute URLs now work (not just relative paths with `base`)

## 0.1.2 (2026-06-06)

- Variable interpolation with `{{name}}` syntax in paths, headers, and body
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "reqsh"
version = "0.1.2"
version = "0.1.3"
edition = "2024"
license = "MIT"
authors = ["Harshil Gupta"]
Expand Down
22 changes: 15 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Interactive HTTP shell for API workflows. Send HTTP requests, manage headers and
- Variable interpolation with `{{name}}` syntax in paths, headers, and body
- Query parameter support with `param: key=value` lines
- Save and run requests in-session
- Response time displayed per request
- Full absolute URL support (base URL not required)
- JSON response pretty-printing
- Command history and rerun by index
- Colored terminal output
Expand All @@ -32,7 +34,7 @@ curl -fsSL https://raw.githubusercontent.com/hars-21/reqsh/main/install.sh | sh

### Pre-built binary

Download the latest binary from the [releases page](https://github.com/hars-21/reqsh/releases/latest).
Download the latest binary for your platform from the [releases page](https://github.com/hars-21/reqsh/releases/latest). macOS (Intel & Silicon), Linux (x86_64), and Windows (x86_64) are available.

### Build from source

Expand All @@ -59,18 +61,24 @@ Start the REPL:
reqsh
```

Set a base URL:
Set a base URL (optional — you can use absolute URLs directly):

```bash
reqsh> base https://api.example.com
```

Send a GET request:
Send a GET request (relative path requires a base URL):

```bash
reqsh> GET /users
```

Or use an absolute URL directly:

```bash
reqsh> GET https://jsonplaceholder.typicode.com/posts
```

Send a POST request with headers and body:

```bash
Expand All @@ -86,10 +94,10 @@ reqsh> POST /users

| Command | Description |
| ---------------------- | ------------------------------------ |
| `GET <path>` | Send GET request |
| `POST <path>` | Send POST request |
| `PUT <path>` | Send PUT request |
| `DELETE <path>` | Send DELETE request |
| `GET <url>` | Send GET request |
| `POST <url>` | Send POST request |
| `PUT <url>` | Send PUT request |
| `DELETE <url>` | Send DELETE request |
| `base <url>` | Set base URL for all requests |
| `header <key> <value>` | Set a global header for all requests |
| `set <name> <value>` | Set a session variable |
Expand Down
23 changes: 17 additions & 6 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,19 @@ echo "Installing $BIN_NAME..."
OS="$(uname -s)"
ARCH="$(uname -m)"

case "$OS" in
Linux)
case "$(echo "$OS" | tr '[:upper:]' '[:lower:]')" in
linux)
OS="unknown-linux-gnu"
EXT="tar.gz"
;;
Darwin)
darwin)
OS="apple-darwin"
EXT="tar.gz"
;;
mingw*|msys*)
OS="pc-windows-msvc"
EXT="zip"
BIN_NAME="reqsh.exe"
;;
*)
echo "Unsupported OS: $OS"
Expand Down Expand Up @@ -50,7 +57,7 @@ if [ -z "$VERSION" ]; then
exit 1
fi

FILE="${BIN_NAME}-${VERSION}-${TARGET}.tar.gz"
FILE="${BIN_NAME}-${VERSION}-${TARGET}.${EXT}"

URL="https://github.com/${REPO}/releases/download/${VERSION}/${FILE}"

Expand All @@ -63,9 +70,13 @@ echo "Downloading $FILE..."
curl -fsSL "$URL" -o "$ARCHIVE_PATH"

echo "Extracting archive..."
tar -xzf "$ARCHIVE_PATH" -C "$TMP_DIR"
if [ "$EXT" = "zip" ]; then
unzip -o "$ARCHIVE_PATH" -d "$TMP_DIR"
else
tar -xzf "$ARCHIVE_PATH" -C "$TMP_DIR"
fi

chmod +x "$TMP_DIR/$BIN_NAME"
chmod +x "$TMP_DIR/$BIN_NAME" 2>/dev/null || true

mkdir -p "$INSTALL_DIR"

Expand Down
11 changes: 7 additions & 4 deletions src/display.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use std::time::Duration;

use colored::Colorize;
use reqwest::blocking::Response;

pub fn display_response(res: Response) -> String {
pub fn display_response(res: Response, response_time: Duration) -> String {
let mut output = String::new();

let status = res.status();
Expand All @@ -18,10 +20,11 @@ pub fn display_response(res: Response) -> String {
};

let status_line = format!(
"{} {} {}\n",
"{} {} {} {}\n",
format!("{:?}", res.version()).magenta(),
status_color.bold(),
reason_color.bold()
status_color,
reason_color,
format!("{}ms", response_time.as_millis()).bright_yellow(),
);

output.push_str(&status_line);
Expand Down
2 changes: 1 addition & 1 deletion src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub fn execute(req: Request, ctx: &ShellState) -> Result<String, String> {
let response = fetch(&req, base_url, global_headers);

match response {
Ok(r) => Ok(display_response(r)),
Ok((res, duration)) => Ok(display_response(res, duration)),
Err(e) => Err(e),
}
}
Expand Down
24 changes: 18 additions & 6 deletions src/runner.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use std::collections::HashMap;
use std::{
collections::HashMap,
time::{Duration, Instant},
};

use crate::request::{Method, Request};
use reqwest::{
Expand All @@ -10,15 +13,18 @@ pub fn fetch(
request: &Request,
base_url: Option<&str>,
global_headers: &HashMap<String, String>,
) -> Result<Response, String> {
) -> Result<(Response, Duration), String> {
// Client
let client = Client::new();

// Url Constructor
let full_url = if (request.path.starts_with("/"))
let full_url = if request.path.starts_with("http://") || request.path.starts_with("https://") {
request.path.clone()
} else if request.path.starts_with("/")
&& let Some(base_url) = base_url
{
format!("{base_url}{}", request.path)
let base = base_url.trim_end_matches('/');
format!("{base}{}", request.path)
} else {
return Err(String::from(
"Base URL not found. Use base <url> to add base url",
Expand Down Expand Up @@ -52,7 +58,9 @@ pub fn fetch(
HeaderValue::from_bytes(value.as_bytes()).unwrap(),
);
}
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
if !headers.contains_key(CONTENT_TYPE) {
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
}
req_builder = req_builder.headers(headers);

// Query Params
Expand All @@ -65,11 +73,15 @@ pub fn fetch(
req_builder = req_builder.body(body.clone());
}

// Timer
let now = Instant::now();

// Response
let result = req_builder.send();
let response_time = now.elapsed();

match result {
Ok(response) => Ok(response),
Ok(response) => Ok((response, response_time)),
Err(e) => Err(format!("{}", e)),
}
}
Loading