Skip to content

Commit

Permalink
docs: write usage guide
Browse files Browse the repository at this point in the history
  • Loading branch information
hougesen committed Oct 29, 2023
1 parent 02fe948 commit bec9534
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 5 deletions.
100 changes: 98 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,104 @@
# hitt

hitt is a HTTP testing tool focused on speed and simplicity.
hitt is a command line HTTP testing tool focused on speed and simplicity.

It started as an alternative to Postman since I was tired of Postman taking a long time to open (on my machine).
## Usage

To send a request create a file ending in `.http`.

The syntax of `.http` files is pretty straightforward:

```
GET https://mhouge.dk/
```

The file can then be run using the following command:

```sh
hitt <PATH_TO_FILE>
```

That is all that is need to send a request.

### Request headers

Request headers can be added by writing key value pairs (`KEY:VALUE`) on a new line after the method and URL:

```
GET https://mhouge.dk/
key:value
```

Leading spaces in the header value is ignored, so `KEY: VALUE` and `KEY:VALUE` will both have the value `VALUE`.

### Request body

A body can be sent with the request by creating a blank line, followed by the desired body input.

Please note, hitt **does not** infer content type. That has to be written as a header.

```
POST https://mhouge.dk/
content-type:application/json
{
"key": "value"
}
```

### Multiple request in single file

Multiple requests can be written in a single file by adding a line with `###` as a separator:

```
GET https://mhouge.dk/
###
GET https://mhouge.dk/
```

### Exiting on 4XX and 5XX status codes

By default, hitt does not exit on error status codes. That behavior can be changed by supplying the `--fail-fast` argument.

```sh
hitt --fail-fast <PATH_TO_FOLDER>
```

### Running all files in directory

The `--recursive` argument can be passed to run all files in a directory:

```sh
hitt --recursive <PATH_TO_FOLDER>
```

The order of each file execution is platform and file system dependent. That might change in the future, but for now you **should not** rely on the order.

### Hiding response headers

The `--hide-headers` argument can be passed to hide the response headers in the output:

```sh
hitt --hide-headers <PATH_TO_FILE>
```

### Hiding response body

The `--hide-body` argument can be passed to hide the response body in the output:

```sh
hitt --hide-body <PATH_TO_FILE>
```

### Disabling pretty printing

The `--disable-formatting` argument can be passed to disable pretty printing of response body:

```sh
hitt --disable-formatting <PATH_TO_FILE>
```

## Disclaimer

Expand Down
6 changes: 3 additions & 3 deletions hitt-cli/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
#[clap(
author = "Mads Hougesen, mhouge.dk",
version,
about = "hitt is a HTTP testing tool focused on speed and simplicity."
about = "hitt is a command line HTTP testing tool focused on speed and simplicity."
)]
pub(crate) struct CliArguments {
/// Path to .http file
/// Path to .http file, or directory if supplied with the `--recursive` argument
#[arg()]
pub(crate) path: String,

/// Exit on error status code
/// Exit on error response status code
#[arg(long, default_value_t = false)]
pub(crate) fail_fast: bool,

Expand Down

0 comments on commit bec9534

Please sign in to comment.