route

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JSON = &jsonProvider{}

JSON json 提供者

Functions

func Del

func Del(pattern string) error

Del 删除指定模式的路由

func Flush

func Flush() error

Flush 刷新路由

func Reset

func Reset(provider Provider)

Reset 重置路由表提供者

func Save

func Save(src *Route) error

Save 保存路由

Types

type Provider

type Provider interface {
	LoadAll() ([]*Route, error)
	Flush(full []*Route, saves []*Route, removes []*Route) error
}

Provider 路由提供者

type Route

type Route struct {
	Pattern   string `json:"pattern"`             // 路由模式字串
	URL       string `json:"url"`                 // 目标url
	KeepAlive bool   `json:"keepalive,omitempty"` // 是否一直保持连接,直到对方断开;默认 false,会在没有人使用时关闭
}

Route 路由

func All

func All() []*Route

All 获取所有的路由

func Get

func Get(pattern string) *Route

Get 获取取指定模式的路由

func Match

func Match(path string) *Route

Match 从路由表中获取和路径匹配的路由实例

func (*Route) CopyFrom

func (r *Route) CopyFrom(src *Route)

CopyFrom 从源拷贝

Jump to

Keyboard shortcuts

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