delay

package module
v0.0.0-...-4426c3b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2017 License: MIT Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

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())
// ...

Documentation

Index

Constants

View Source
const DelayHeader = "X-Add-Delay"

DelayHeader can have value like 300ms 2.5s and 0.5m

Variables

This section is empty.

Functions

func New

func New() echo.MiddlewareFunc

New add delays latency to your endpoint

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL