# Quick Start

1. Download the `httpstub` JAR file from the Github repository's releases page. Or download docker image from [`ghcr.io`](https://ghcr.io/gleb619/httpstub)
2.  Create folder for stubs

    ```bash
    mkdir -p data
    ```
3. Create a YAML file `api-definition.yaml` at `data` folder with the API definition.&#x20;

Here's an example YAML file that defines a simple endpoint that returns a static JSON response:

```yaml
#data/api-definition.yaml
rules:
  request:
    path: /hello
  response:
    body: Hello, world!
```

This YAML file specifies that when an HTTP GET request is received with a path of `/hello`, the server should respond with a 200 status code and a plain text containing the message "Hello, world!".

4. Run the `httpstub` server using the following command(_replacing `httpstub.jar` with the name of the JAR file you downloaded in step 1_):

```sh
STUB_DATA=$(pwd)/data java -jar httpstub.jar
```

This will start the `httpstub` server and load the API definition from the YAML file from `$(pwd)/data` (folder with data from our current location).

5. Test the `httpstub` server by sending an HTTP GET request to the endpoint defined in the YAML file. For example, if you're running the server on `localhost` port `8080`, you can use a tool like `curl` to send the request:

```bash
curl http://localhost:8080/hello
```

This should return the following response:

```
Hello, world!s
```

That's it! You've successfully set up and tested an `httpstub` server using a YAML API definition file.

### Docker

Docker image is available on [`ghcr.io/gleb619/httpstub`](https://ghcr.io/gleb619/httpstub)

```
docker run -v $PWD/data:/app/data:ro -p 8080:8080 ghcr.io/gleb619/httpstub
```
