<commit_before># delay
Middleware for adding delays (latency) to your endpoint. Intended to simulate latency for testing it's effects on faster networks.

Add a delay of a specified duration by adding an http header to your request.

The header name is `X-Add-Delay`. The value can be any value parsable by [golang's time.ParseDuration](http://golang.org/pkg/time/#ParseDuration).

If the value is not parsable it will not add any latency. It will behave as if the header wasn't there at all.

Sorry, adding negative delay won't speed up your endpoints :p

## Examples

`X-Add-Delay: 300ms`

`X-Add-Delay: 2.5s`
<commit_msg>add how to use with negroni section<commit_after># delay
Middleware for adding delays (latency) to your endpoint. Intended to simulate latency for testing its effects on faster networks.

Add a delay of a specified duration by adding an http header to your request.

The header name is `X-Add-Delay`. The value can be any value parsable by [golang's time.ParseDuration](http://golang.org/pkg/time/#ParseDuration). For example, `300ms`, `2.5s`, and `0.5m` are all valid values. Technically `-1.5s` is a valid value, but it won't actually speed up your end point :p

If the value is not parsable it will not add any latency. It will behave as if the header wasn't there at all.

## Header Examples

`X-Add-Delay: 300ms`

`X-Add-Delay: 2.5s`

## How to use it with negroni

There is no configuration.

Just slip it in as negroni middleware:

	import (
	    "github.com/codegangsta/negroni"
	    "github.com/jeffbmartinez/delay"
	)
	
    n := negroni.New(...)
	n.Use(delay.Middleware{})
	// ...

{'fraction_non_alphanumeric': 0.09164086687306501, 'fraction_numerical': 0.011764705882352941, 'mean_word_length': 3.8238805970149254, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1103537', 'n_tokens_mistral': 528, 'n_tokens_neox': 486, 'n_words': 224}