Skip to content

Commit

Permalink
docs: create layout for documentation website
Browse files Browse the repository at this point in the history
  • Loading branch information
hougesen committed Dec 24, 2023
1 parent 11cf7c0 commit ed931fd
Show file tree
Hide file tree
Showing 7 changed files with 222 additions and 3 deletions.
6 changes: 4 additions & 2 deletions docs/app.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<template>
<div class="w-full min-h-screen h-full">
<NuxtPage />
<div class="min-h-screen h-full flex gap-8 p-8 w-full">
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
</div>
</template>
153 changes: 153 additions & 0 deletions docs/content/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# hitt

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

## Install

hitt can be installed using Cargo, the package manager for Rust.

```sh
cargo install hitt
```

## Usage

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

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

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

The file can then be run using the following command:

```sh
hitt run <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:

```text
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.

```text
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:

```text
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 run --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 run --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 run --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 run --hide-body <PATH_TO_FILE>
```

### Disabling pretty printing

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

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

## Neovim

hitt can be run directly from Neovim.

> [!NOTE]
> The `hitt` executable must be available in your path for the plugin to work.
### Install

#### Lazy

```lua
local hitt_plugin = {
"hougesen/hitt",
opts = {},
}
```

### Usage

The plugin exposes a single command `:HittSendRequest`, which can be bound to a keymap like this:

```lua
-- ~/.config/nvim/after/plugin/hitt.lua

local hitt = require("hitt")

vim.keymap.set("n", "<leader>rr", hitt.HittSendRequest, {})
```

![hitt neovim window](/docs/public/hitt-neovim-window.png)

### Configuration

| Name | Default | Description |
| ------------- | ------- | --------------------------------- |
| window_width | 80 | Window width in percentage |
| window_height | 80 | Window height in percentage |
| fail_fast | false | Enables the `--fail-fast` options |

## Disclaimer

hitt is most likely not ready for main stream usage. I ([Mads Hougesen](https://mhouge.dk)) am primarily developing it based on features I believe to be useful, or fun to develop.
5 changes: 5 additions & 0 deletions docs/layouts/default.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<article class="mx-auto container prose lg:prose-xl">
<slot></slot>
</article>
</template>
11 changes: 11 additions & 0 deletions docs/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,15 @@ export default defineNuxtConfig({
},

css: ['~/assets/css/main.css'],

content: {
documentDriven: true,

highlight: {
theme: {
default: 'github-dark',
},
preload: ['sh', 'lua'],
},
},
});
47 changes: 47 additions & 0 deletions docs/package-lock.json

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

1 change: 1 addition & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
},
"devDependencies": {
"@nuxt/devtools": "latest",
"@tailwindcss/typography": "^0.5.10",
"autoprefixer": "^10.4.16",
"nuxt": "^3.8.2",
"postcss": "^8.4.32",
Expand Down
2 changes: 1 addition & 1 deletion docs/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ export default {
theme: {
extend: {},
},
plugins: [],
plugins: [require('@tailwindcss/typography')],
} satisfies Config;

0 comments on commit ed931fd

Please sign in to comment.