<commit_before>## Why?
Sometimes you need to test how your application handles slow/buggy
external APIs. If you can easily configure API server domain name, then goslow will help you.

## Quick start
Let's say you're developing an application against the Facebook graph API and
you want to know what will happen when the endpoint *graph.facebook.com/me* responds in 10 seconds.

Just configure your app to make requests to *10.goslow.link* instead of *graph.facebook.com*
and you're set:

```shell
time curl 10.goslow.link/me
{"goslow": "response"}
10.423 total
```

Well, almost set, because you've got a canned response **{"goslow": "response"}**.
You probably wanted to get the usual graph API response: **{"name": "zuck", "gender": "male"}**.  
No worries, we'll get to that later.

By the way, different endpoints and POST requests also work:
```shell
time curl -X POST -d 'your payload' '10.goslow.link/me/feed?message="test"'
{"goslow": "response"}
10.223 total
```

Need to simulate a 6 seconds delay? Just use *6.goslow.link* instead of *10.goslow.link*


```shell
time curl 6.goslow.link/any-endpoint-works
{"goslow": "response"}
6.178 total
```

Need to simulate some serious delay? Use *99.goslow.link*:
```shell
time curl 99.goslow.link/me
{"goslow": "response"}
99.204 total
```

Need to simulate a 500 seconds delay? Use *500.goslow.link*, right?

Nope. Domains *100.goslow.link*, *101.goslow.link*, ..., *599.goslow.link* respond with
HTTP status code 100, 101, ..., 599 without any delay:

```shell
time curl -w "%{http_code}" 500.goslow.link/me
{"goslow": "response"}500
0.152 total
```

*301.goslow.link* and *302.goslow.link* redirect to *0.goslow.link*:

```shell
time curl -w "%{redirect_url}" 302.goslow.link/me
{"goslow": "response"}HTTP://0.goslow.link
0.107 total
```

## Not-so-quick start
> No worries, we'll get to that later.

Remember that bit? Well, it's later time!

Back to the Facebook graph API example.
Let's say you're using the endpoint *graph.facebook.com/me* and you want to:
1. Slow it down by 5 seconds.
2. Get **{"name": "zuck", "gender": "male"}** in response.

Just make a POST request to *create.goslow.link/me?delay=5* with the payload **{"name": "zuck", "gender": "male"}** and you're set.
```shell
curl -d '{"name": "zuck", "gender": "male"}' 'create.goslow.link/me?delay=5'
Hooray!
Endpoint http://5wx55yijr.goslow.link/me responds to any HTTP method with 5s delay.
Response is: {"name": "zuck", "gender": "male"}

Your personal goslow domain is 5wx55yijr.goslow.link
...
```
Awesome, you're *really* set this time:

```shell
time curl 5wx55yijr.goslow.link/me
{"name": "zuck", "gender": "male"}
5.382 total
```

Now, what's the deal with the "*your personal goslow domain is 5wx55yijr.goslow.link*"? Well, the domain *5wx55yijr.goslow.link* is all yours and you can add different endpoints to it.

Quick aside:
when *you* POST to *create.goslow.link* your personal goslow domain will be a little different
from the *5wx55yijr.goslow.link*. Domain names are randomly generated. For the sake of example let's pretend that the randomly
generated domain name was *5wx55yijr.goslow.link*.
End of quick aside.


You can add new endpoints by POSTing to *admin-5wx55yijr.goslow.link*  
Let's make the endpoint *5wx55yijr.goslow.link/another/* to respond to POST requests with **{"another": "response"}**
and 3.4 seconds delay:
```shell
curl -d '{"another": "response"}' 'admin-5wx55yijr.goslow.link/another/?delay=3.4&method=POST'
Hooray!
Endpoint http://5wx55yijr.goslow.link/another/ responds to POST with 3.4s delay.
Response is: {"another": "response"}
```

Now you have two urls sending different responses with different delays.
```shell
time curl -d 'any payload' 5wx55yijr.goslow.link/another/
'{"another": "response"}'
3.482 total
```

```shell
time curl 5wx55yijr.goslow.link/me
{"name": "zuck", "gender": "male"}
5.028 total
```

The sky's the limit.

Worried whether slow javascript CDN will bring your app down? Goslow've got you covered:
```shell
curl ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js | curl -d @- "admin-5wx55yijr.goslow.link/ajax/libs/jquery/2.1.1/jquery.min.js?delay=20"

Hooray!
Endpoint http://5wx55yijr.goslow.link/ajax/libs/jquery/2.1.1/jquery.min.js responds to any HTTP method with 20s delay.
Response is: /*! jQuery v2.1.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/licen...
```

## Slow start
If you think that storing your data on unprotected-by-passwords-third-party-domains is not a great idea, then you're absolutely right.

The solution is to install goslow locally.

### Installation
[Download](github.com/alexandershov/goslow/releases) a precompiled binary for your operating system.

If you're feeling adventurous, you can [build goslow from source.](github.com/alexandershov/goslow/Build.md)

### Usage

Start server:
```shell
./goslow # or goslow.exe if you're on Windows
# listening on localhost:5103
```

By default goslow runs in a single domain mode<commit_msg>Fix broken links in README<commit_after>## Why?
Sometimes you need to test how your application handles slow/buggy
external APIs. If you can easily configure API server domain name, then goslow will help you.

## Quick start
Let's say you're developing an application against the Facebook graph API and
you want to know what will happen when the endpoint *graph.facebook.com/me* responds in 10 seconds.

Just configure your app to make requests to *10.goslow.link* instead of *graph.facebook.com*
and you're set:

```shell
time curl 10.goslow.link/me
{"goslow": "response"}
10.423 total
```

Well, almost set, because you've got a canned response **{"goslow": "response"}**.
You probably wanted to get the usual graph API response: **{"name": "zuck", "gender": "male"}**.  
No worries, we'll get to that later.

By the way, different endpoints and POST requests also work:
```shell
time curl -X POST -d 'your payload' '10.goslow.link/me/feed?message="test"'
{"goslow": "response"}
10.223 total
```

Need to simulate a 6 seconds delay? Just use *6.goslow.link* instead of *10.goslow.link*


```shell
time curl 6.goslow.link/any-endpoint-works
{"goslow": "response"}
6.178 total
```

Need to simulate some serious delay? Use *99.goslow.link*:
```shell
time curl 99.goslow.link/me
{"goslow": "response"}
99.204 total
```

Need to simulate a 500 seconds delay? Use *500.goslow.link*, right?

Nope. Domains *100.goslow.link*, *101.goslow.link*, ..., *599.goslow.link* respond with
HTTP status code 100, 101, ..., 599 without any delay:

```shell
time curl -w "%{http_code}" 500.goslow.link/me
{"goslow": "response"}500
0.152 total
```

*301.goslow.link* and *302.goslow.link* redirect to *0.goslow.link*:

```shell
time curl -w "%{redirect_url}" 302.goslow.link/me
{"goslow": "response"}HTTP://0.goslow.link
0.107 total
```

## Not-so-quick start
> No worries, we'll get to that later.

Remember that bit? Well, it's later time!

Back to the Facebook graph API example.
Let's say you're using the endpoint *graph.facebook.com/me* and you want to:
1. Slow it down by 5 seconds.
2. Get **{"name": "zuck", "gender": "male"}** in response.

Just make a POST request to *create.goslow.link/me?delay=5* with the payload **{"name": "zuck", "gender": "male"}** and you're set.
```shell
curl -d '{"name": "zuck", "gender": "male"}' 'create.goslow.link/me?delay=5'
Hooray!
Endpoint http://5wx55yijr.goslow.link/me responds to any HTTP method with 5s delay.
Response is: {"name": "zuck", "gender": "male"}

Your personal goslow domain is 5wx55yijr.goslow.link
...
```
Awesome, you're *really* set this time:

```shell
time curl 5wx55yijr.goslow.link/me
{"name": "zuck", "gender": "male"}
5.382 total
```

Now, what's the deal with the "*your personal goslow domain is 5wx55yijr.goslow.link*"? Well, the domain *5wx55yijr.goslow.link* is all yours and you can add different endpoints to it.

Quick aside:
when *you* POST to *create.goslow.link* your personal goslow domain will be a little different
from the *5wx55yijr.goslow.link*. Domain names are randomly generated. For the sake of example let's pretend that the randomly
generated domain name was *5wx55yijr.goslow.link*.
End of quick aside.


You can add new endpoints by POSTing to *admin-5wx55yijr.goslow.link*  
Let's make the endpoint *5wx55yijr.goslow.link/another/* to respond to POST requests with **{"another": "response"}**
and 3.4 seconds delay:
```shell
curl -d '{"another": "response"}' 'admin-5wx55yijr.goslow.link/another/?delay=3.4&method=POST'
Hooray!
Endpoint http://5wx55yijr.goslow.link/another/ responds to POST with 3.4s delay.
Response is: {"another": "response"}
```

Now you have two urls sending different responses with different delays.
```shell
time curl -d 'any payload' 5wx55yijr.goslow.link/another/
'{"another": "response"}'
3.482 total
```

```shell
time curl 5wx55yijr.goslow.link/me
{"name": "zuck", "gender": "male"}
5.028 total
```

The sky's the limit.

Worried whether slow javascript CDN will bring your app down? Goslow've got you covered:
```shell
curl ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js | curl -d @- "admin-5wx55yijr.goslow.link/ajax/libs/jquery/2.1.1/jquery.min.js?delay=20"

Hooray!
Endpoint http://5wx55yijr.goslow.link/ajax/libs/jquery/2.1.1/jquery.min.js responds to any HTTP method with 20s delay.
Response is: /*! jQuery v2.1.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/licen...
```

## Slow start
If you think that storing your data on unprotected-by-passwords-third-party-domains is not a great idea, then you're absolutely right.

The solution is to install goslow locally.

### Installation
[Download](https://github.com/alexandershov/goslow/releases) a precompiled binary for your operating system.

If you're feeling adventurous, you can [build goslow from source.](https://github.com/alexandershov/goslow/blob/master/Build.md)

### Usage

Start server:
```shell
./goslow # or goslow.exe if you're on Windows
# listening on localhost:5103
```

By default goslow runs in a single domain mode
{'fraction_non_alphanumeric': 0.1398139813981398, 'fraction_numerical': 0.036403640364036406, 'mean_word_length': 4.546311702717693, 'pattern_counts': {'":': 50, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '583479', 'n_tokens_mistral': 3722, 'n_tokens_neox': 3283, 'n_words': 1201}