timeout

package
v1.36.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2021 License: MIT Imports: 4 Imported by: 0

README

Timeout

Timeout middleware for Fiber wraps a fiber.Handler with a timeout. If the handler takes longer than the given duration to return, the timeout error is set and forwarded to the centralized ErrorHandler.

Table of Contents
Signatures
func New(h fiber.Handler, t time.Duration) fiber.Handler
Examples

Import the middleware package that is part of the Fiber web framework

import (
  "github.com/gofiber/fiber/v2"
  "github.com/gofiber/fiber/v2/middleware/timeout"
)

After you initiate your Fiber app, you can use the following possibilities:

handler := func(ctx *fiber.Ctx) error {
	err := ctx.SendString("Hello, World 👋!")
	if err != nil {
		return err
	}
	return nil
}

app.Get("/foo", timeout.New(handler, 5 * time.Second))

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(handler fiber.Handler, timeout time.Duration) fiber.Handler

New wraps a handler and aborts the process of the handler if the timeout is reached

Types

This section is empty.

Jump to

Keyboard shortcuts

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