middleware

package module
v4.0.3 Latest Latest
Warning

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

Go to latest
Published: May 11, 2021 License: MIT Imports: 2 Imported by: 0

README

middleware

Build Status license codecov PkgGoDev Go version

middleware Go HTTP 的中间件,提供了大部分实用的功能。

可以选择与 mux 一起使用; 也可以采用 Manager 直接与标准库的 net/http 一起使用。

  • auth 基本的验证处理;
  • compress 对内容进行压缩;
  • errorhandler 处理各类状态码下的输出;
  • header 输出指定的报头;
  • health 接口状态的监测;
  • ratelimit x-rate-limit 的相关实现;
  • recovery 对 Panic 的处理;
  • debugger 用于输出测试的中间件;

安装

go get github.com/issue9/middleware/v4

版权

本项目采用 MIT 开源授权许可证,完整的授权说明可在 LICENSE 文件中找到。

Documentation

Overview

Package middleware 包含了一系列 http.Handler 接口的中间件

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Middlewares

type Middlewares = mux.Middlewares

Middlewares 中间件管理

func NewMiddlewares

func NewMiddlewares(next http.Handler) *Middlewares

NewMiddlewares 声明新的 Middlewares 实例

Directories

Path Synopsis
Package auth 验证类的中间件
Package auth 验证类的中间件
basic
Package basic 实现 Basic 校验 https://tools.ietf.org/html/rfc7617
Package basic 实现 Basic 校验 https://tools.ietf.org/html/rfc7617
Package compress 提供一个支持内容压缩的中间件
Package compress 提供一个支持内容压缩的中间件
Package debugger 提供测试和性能测试相关的中间件
Package debugger 提供测试和性能测试相关的中间件
Package errorhandler 提供自定义错误页面的功能
Package errorhandler 提供自定义错误页面的功能
Package header 用于指定输出的报头
Package header 用于指定输出的报头
Package health API 状态检测
Package health API 状态检测
Package ratelimit 提供了 X-Rate-Limit 功能的中间件 X-Rate-Limit-Limit: 同一个时间段所允许的请求的最大数目; X-Rate-Limit-Remaining: 在当前时间段内剩余的请求的数量; X-Rate-Limit-Reset: 为了得到最大请求数所等待的秒数。
Package ratelimit 提供了 X-Rate-Limit 功能的中间件 X-Rate-Limit-Limit: 同一个时间段所允许的请求的最大数目; X-Rate-Limit-Remaining: 在当前时间段内剩余的请求的数量; X-Rate-Limit-Reset: 为了得到最大请求数所等待的秒数。
Package recovery 提供了处理 panic 操作的中间件 recovery.RecoverFunc(func(w http.ResponseWriter, msg interface{}) { fmt.Printf("recovery: %s", msg) }).MiddlewareFunc(func(w http.ResponseWriter, r *http.Request){ panic("panic") })
Package recovery 提供了处理 panic 操作的中间件 recovery.RecoverFunc(func(w http.ResponseWriter, msg interface{}) { fmt.Printf("recovery: %s", msg) }).MiddlewareFunc(func(w http.ResponseWriter, r *http.Request){ panic("panic") })

Jump to

Keyboard shortcuts

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