<commit_before># reqbot

* [![Build Status](https://travis-ci.org/typingincolor/reqbot.svg?branch=master)](https://travis-ci.org/typingincolor/reqbot) - Master
* [![Build Status](https://travis-ci.org/typingincolor/reqbot.svg?branch=v1)](https://travis-ci.org/typingincolor/reqbot) - v1

## What is it?

reqbot is a programmable mock backend to allow you test your application is calling a web api correctly.

You can tell reqbot what response you want when your client calls the api, all from inside your unit or integration tests.

## Example usage

This is a ruby example

``` ruby
require 'rest-client'
require 'json'

# this is the body of the response you want to recieve
random_body = (0...10).map { ('a'..'z').to_a[rand(26)] }.join

# you can also tell reqbot what headers to put in the response
programmed_response = {'headers' => {'header1' => 'value1'}, 'body' => random_body}

# tell reqbot about the response you want
saved_response_result = RestClient.post 'http://localhost:8080/response',
                                        programmed_response.to_json,
                                        :content_type => :json

# reqbot tells gives you a uuid for the response so you can ask for it
r = JSON.parse(saved_response_result)

# reqbot will store your request in a bucket so you can look at it later, 
# this example will store it in the andrew bucket.
#
# you can specify the response by putting the it's uuid as a path parameter
RestClient.get 'http://localhost:8080/bucket/andrew/' + r['uuid']

# or in the X-REQBOT-RESPONSE header
RestClient.get 'http://localhost:8080/bucket/andrew', 'X-REQBOT-RESPONSE' => r['uuid']
```

## Magic Headers
There are three magic headers that reqbot uses when calling a bucket:

`X-REQBOT-GO-SlOW` if you set this to a number, then reqbot will wait that number of milliseconds before sending the response.

`X-REQBOT-HTTP-CODE` this tell reqbot what HTTP status code to return to you

`X-REQBOT-RESPONSE` this tells reqbot what response to send back

## Web App
Reqbot has a web application at `/` which allows you to see the requests that reqbot has received.
<commit_msg>added startup instructions<commit_after># reqbot

* [![Build Status](https://travis-ci.org/typingincolor/reqbot.svg?branch=master)](https://travis-ci.org/typingincolor/reqbot) - Master
* [![Build Status](https://travis-ci.org/typingincolor/reqbot.svg?branch=v1)](https://travis-ci.org/typingincolor/reqbot) - v1

## What is it?

reqbot is a programmable mock backend to allow you test your application is calling a web api correctly.

You can tell reqbot what response you want when your client calls the api, all from inside your unit or integration tests.

## Example usage

This is a ruby example

``` ruby
require 'rest-client'
require 'json'

# this is the body of the response you want to recieve
random_body = (0...10).map { ('a'..'z').to_a[rand(26)] }.join

# you can also tell reqbot what headers to put in the response
programmed_response = {'headers' => {'header1' => 'value1'}, 'body' => random_body}

# tell reqbot about the response you want
saved_response_result = RestClient.post 'http://localhost:8080/response',
                                        programmed_response.to_json,
                                        :content_type => :json

# reqbot tells gives you a uuid for the response so you can ask for it
r = JSON.parse(saved_response_result)

# reqbot will store your request in a bucket so you can look at it later, 
# this example will store it in the andrew bucket.
#
# you can specify the response by putting the it's uuid as a path parameter
RestClient.get 'http://localhost:8080/bucket/andrew/' + r['uuid']

# or in the X-REQBOT-RESPONSE header
RestClient.get 'http://localhost:8080/bucket/andrew', 'X-REQBOT-RESPONSE' => r['uuid']
```

## Magic Headers
There are three magic headers that reqbot uses when calling a bucket:

`X-REQBOT-GO-SlOW` if you set this to a number, then reqbot will wait that number of milliseconds before sending the response.

`X-REQBOT-HTTP-CODE` this tell reqbot what HTTP status code to return to you

`X-REQBOT-RESPONSE` this tells reqbot what response to send back

## Web App
Reqbot has a web application at `/` which allows you to see the requests that reqbot has received.


## Running reqbot

You will need to install redis and gradle...

Then `gradle run`

This will start everything at `http://localhost:8080/`
{'fraction_non_alphanumeric': 0.10106503512349875, 'fraction_numerical': 0.010423748017221844, 'mean_word_length': 3.710779082177161, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3413462', 'n_tokens_mistral': 1348, 'n_tokens_neox': 1308, 'n_words': 521}