Skip to content
/ delay Public
forked from jeffbmartinez/delay

Middleware for adding delays (latency) to your endpoint. Intended for testing effects of higher latency on fast networks.

License

Notifications You must be signed in to change notification settings

beenote/delay

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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. 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 echo v3

There is no configuration.

Just slip it in as echo middleware:

import (
    "github.com/labstack/echo"
    "github.com/beenote/delay"
)

e := echo.New()
e.Use(delay.New())
// ...

About

Middleware for adding delays (latency) to your endpoint. Intended for testing effects of higher latency on fast networks.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%