-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d978df7
commit e1b689d
Showing
1 changed file
with
18 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,29 @@ | ||
# delay | ||
Middleware for adding delays (latency) to your endpoint. Intended to simulate latency for testing it's effects on faster networks. | ||
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). | ||
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. | ||
|
||
Sorry, adding negative delay won't speed up your endpoints :p | ||
|
||
## Examples | ||
## 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{}) | ||
// ... |