host

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package host 提供了限定访问域名的中间件。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(next http.Handler, domains ...string) http.Handler

New 声明一个限定域名的中间件.

若请求的域名不允许,会返回 404 错误。 若 domains 为空,则任何请求都将返回 404。

仅会将域名与 domains 进行比较,端口与协议都将不参写比较。 domains 可以是泛域名,比如 *.example.com,但不能是 s1.*.example.com

Types

type Switcher added in v1.2.0

type Switcher struct {
	// contains filtered or unexported fields
}

Switcher 实现按域名进行路由

func NewSwitcher added in v1.2.0

func NewSwitcher() *Switcher

NewSwitcher 声明新的 Switcher 实例

func (*Switcher) AddHost added in v1.2.0

func (s *Switcher) AddHost(h http.Handler, domain ...string)

AddHost 添加域名信息

domain 可以是泛域名,比如 *.example.com,但不能是 s1.*.example.com

func (*Switcher) ServeHTTP added in v1.2.0

func (s *Switcher) ServeHTTP(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis
Package switcher 按域名进行路由分类
Package switcher 按域名进行路由分类

Jump to

Keyboard shortcuts

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