version

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package version 提供一个限定版本号的中间件

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Version

type Version struct {
	Version string
	Strict  bool // 在没有指定版本号时的处理方式,是否统一采用拒绝访问。
}

Version 限定版本号的中间件

从请求报头的 Accept 中解析相应的版本号,不区分大小写。

当版本号不匹配时,返回 404 错误信息。

若要将版本号放在路径中,可以直接使用 https://github.com/issue9/mux.Prefix 对象

func (*Version) Middleware

func (v *Version) Middleware(next http.Handler) http.Handler

Middleware 将当前中间件应用于 next

func (*Version) MiddlewareFunc

func (v *Version) MiddlewareFunc(next func(w http.ResponseWriter, r *http.Request)) http.Handler

Middleware 将当前中间件应用于 next

Jump to

Keyboard shortcuts

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