Skip to content

Commit

Permalink
use jsonc in code blocks
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Ludes <[email protected]>
  • Loading branch information
deerbone committed Oct 16, 2024
1 parent 2466739 commit a22df5e
Showing 1 changed file with 42 additions and 32 deletions.
74 changes: 42 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,37 @@ Killgrave is a simulator for HTTP-based APIs, in simple words a **Mock Server**,
[![FriendsOfGo](https://img.shields.io/badge/powered%20by-Friends%20of%20Go-73D7E2.svg)](https://friendsofgo.tech)

# Table of Content
- [Overview](#overview)
- [Concepts](#concepts)
* [Imposters](#imposters)
- [Installing](#installing)
* [Homebrew](#homebrew)
* [Docker](#docker)
* [Compile by yourself](#compile-by-yourself)
* [Other](#other)
- [Getting Started](#getting-started)
* [Using Killgrave by command line](#using-killgrave-from-the-command-line)
* [Using Killgrave by config file](#using-killgrave-by-config-file)
* [Configure CORS](#configure-cors)
* [Preparing Killgrave for Proxy Mode](#preparing-killgrave-for-proxy-mode)
* [Creating an Imposter](#creating-an-imposter)
* [Imposters structure](#imposters-structure)
* [Using regex in imposters](#using-regex-in-imposters)
* [Creating an imposter using JSON Schema](#creating-an-imposter-using-json-schema)
* [Creating an imposter with delay](#creating-an-imposter-with-delay)
* [Creating an imposter with dynamic responses](#creating-an-imposter-with-dynamic-responses)
- [Contributing](#contributing)
- [License](#license)
- [Killgrave](#killgrave)
- [Table of Content](#table-of-content)
- [Overview](#overview)
- [Concepts](#concepts)
- [Imposters](#imposters)
- [Installing](#installing)
- [Homebrew](#homebrew)
- [Docker](#docker)
- [Compile by yourself](#compile-by-yourself)
- [Other](#other)
- [Getting Started](#getting-started)
- [Using Killgrave from the command line](#using-killgrave-from-the-command-line)
- [Using Killgrave by config file](#using-killgrave-by-config-file)
- [How to use](#how-to-use)
- [Configure CORS](#configure-cors)
- [Preparing Killgrave for Proxy Mode](#preparing-killgrave-for-proxy-mode)
- [Creating an Imposter](#creating-an-imposter)
- [Imposters Structure](#imposters-structure)
- [Request](#request)
- [Response](#response)
- [Using regex in imposters](#using-regex-in-imposters)
- [Regex in the endpoint](#regex-in-the-endpoint)
- [Regex in the query parameters:](#regex-in-the-query-parameters)
- [Regex in the headers:](#regex-in-the-headers)
- [Creating an imposter using JSON Schema](#creating-an-imposter-using-json-schema)
- [Creating an imposter with delay](#creating-an-imposter-with-delay)
- [Creating an imposter with dynamic responses](#creating-an-imposter-with-dynamic-responses)
- [Using Templating in Responses](#using-templating-in-responses)
- [Available custom templating functions](#available-custom-templating-functions)
- [Contributing](#contributing)
- [License](#license)

## Overview

Expand Down Expand Up @@ -71,7 +81,7 @@ You can learn more about how to configure imposters in the [Imposter Configurati
You can install Killgrave in different ways, but all of them are very simple:

### Homebrew
### Homebrew

If you are a Mac user, you can install Killgrave using [Homebrew](https://brew.sh/):

Expand Down Expand Up @@ -219,29 +229,29 @@ If you want to use `killgrave` from a client application you should consider con
In the CORS section of the file you can find the following options:
- **methods** (string array)
Represents the **Access-Control-Request-Method header**, if you don't specify it or if you leave it as an empty array, the default values will be:
`"GET", "HEAD", "POST", "PUT", "OPTIONS", "DELETE", "PATCH", "TRACE", "CONNECT"`
- **headers** (string array)
Represents the **Access-Control-Request-Headers header**, if you don't specify it or if you leave it as an empty array, the default values will be:
`"X-Requested-With", "Content-Type", "Authorization"`
- **exposed_headers** (string array)
Represents the **Access-Control-Expose-Headers header**, if you don't specify it or if you leave it as an empty array, the default values will be:
`"Cache-Control", "Content-Language", "Content-Type", "Expires", "Last-Modified", "Pragma"`
- **origins** (string array)
Represents the **Access-Control-Allow-Origin header**, if you don't specify it or if you leave it as an empty array this option has not default value
- **allow_credentials** (boolean)
Enables or disables the **Access-Control-Allow-Credentials header**.
### Preparing Killgrave for Proxy Mode
Expand All @@ -264,7 +274,7 @@ We use a rule-based system to match requests to imposters. Therefore, you have t
{
"request": {
"method": "GET",
"endpoint": "/gophers/01D8EMQ185CA8PRGE20DKZTGSR"
"endpoint": "/gophers/01D8EMQ185CA8PRGE20DKZTGSR"
},
"response": {
"status": 200,
Expand Down Expand Up @@ -592,7 +602,7 @@ Since query parameters can be used more than once, they are stored in an array a

Here is an example that includes query parameters gopherColor and gopherAge in the response, one of which can be used more than once:

````json
````jsonc
// expects a request to, for example, GET /gophers/bca49e8a-82dd-4c5d-b886-13a6ceb3744b?gopherColor=Blue&gopherColor=Purple&gopherAge=42
[
{
Expand Down Expand Up @@ -621,7 +631,7 @@ This example also showcases the functions `timeNow`, `timeUTC`, `timeAdd`, `time

Here is an example that includes the request body in the response:

````json
````jsonc
// imposters/gophers.imp.json
[
{
Expand All @@ -647,7 +657,7 @@ Here is an example that includes the request body in the response:
}
]
````
````tmpl
````jsonc
// responses/create_gopher_response.json.tmpl
{
"data": {
Expand All @@ -665,7 +675,7 @@ Here is an example that includes the request body in the response:
}

````
````json
````jsonc
// request body to POST /gophers/bca49e8a-82dd-4c5d-b886-13a6ceb3744b?gopherColor=Blue&gopherColor=Purple&gopherAge=42
{
"data": {
Expand Down

0 comments on commit a22df5e

Please sign in to comment.