Categorygithub.com/justlazydog/gin-timeout
modulepackage
1.0.0
Repository: https://github.com/justlazydog/gin-timeout.git
Documentation: pkg.go.dev

# README

gin-timeout

A middleware to control timeout for gin

Inspired

github.com/vearne/gin-timeout

github.com/gin-contrib/timeout

Example

package main

import (
	"net/http"
	"time"

	"github.com/gin-gonic/gin"
	timeout "github.com/justlazydog/gin-timeout"
)

func main() {
	r := gin.Default()
	r.GET("/hello", timeout.New(
		timeout.WithTimeout(time.Second),
		timeout.WithResponseCode(http.StatusRequestTimeout),
		timeout.WithResponseMsg("request has timeout"),
	), func(c *gin.Context) {
		time.Sleep(3 * time.Second)
		c.JSON(200, "hello")
	})

	r.Run(":8000")
}

# Packages

No description provided by the author

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author

# Type aliases

No description provided by the author