subdomains

package
v1.10.9 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: Apache-2.0 Imports: 11 Imported by: 87

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default = New()

Functions

func SetBaseURL added in v1.6.0

func SetBaseURL(name string, url string)

Types

type Dispatcher added in v1.4.0

type Dispatcher func(r engine.Request, w engine.Response) (*echo.Echo, bool)

type Info

type Info struct {
	Protocol string
	Name     string
	Host     string
	*echo.Echo
}

func (*Info) RelativeURL added in v1.7.15

func (info *Info) RelativeURL(s *Subdomains, uri string) string

func (*Info) RelativeURLByName added in v1.7.15

func (info *Info) RelativeURLByName(s *Subdomains, name string, args ...interface{}) string

func (*Info) URL added in v1.6.0

func (info *Info) URL(s *Subdomains, uri string) string

func (*Info) URLByName added in v1.6.0

func (info *Info) URLByName(s *Subdomains, name string, args ...interface{}) string

type SafeMap added in v1.10.5

type SafeMap[T any] struct {
	// contains filtered or unexported fields
}

func InitSafeMap added in v1.10.5

func InitSafeMap[T any]() SafeMap[T]

func NewSafeMap added in v1.10.5

func NewSafeMap[T any]() *SafeMap[T]

func (*SafeMap[T]) ClearEmpty added in v1.10.5

func (a *SafeMap[T]) ClearEmpty(f func(key string, val T) bool)

func (*SafeMap[T]) Get added in v1.10.5

func (a *SafeMap[T]) Get(key string) T

func (*SafeMap[T]) GetOk added in v1.10.5

func (a *SafeMap[T]) GetOk(key string) (T, bool)

func (*SafeMap[T]) Gets added in v1.10.5

func (a *SafeMap[T]) Gets(keys ...string) []T

func (*SafeMap[T]) GetsFunc added in v1.10.5

func (a *SafeMap[T]) GetsFunc(keys ...func() string) []T

func (*SafeMap[T]) Range added in v1.10.5

func (a *SafeMap[T]) Range(f func(key string, val T) bool)

func (*SafeMap[T]) Remove added in v1.10.5

func (a *SafeMap[T]) Remove(keys ...string)

func (*SafeMap[T]) Reset added in v1.10.6

func (a *SafeMap[T]) Reset()

func (*SafeMap[T]) Set added in v1.10.5

func (a *SafeMap[T]) Set(key string, info T)

func (*SafeMap[T]) Size added in v1.10.5

func (a *SafeMap[T]) Size() int

type Subdomains

type Subdomains struct {
	Hosts    SafeMap[*[]string] //{host:name}
	Alias    SafeMap[*Info]
	Prefixes []string

	Default  string //default name
	Protocol string //http/https
	Boot     string
	// contains filtered or unexported fields
}

func New

func New() *Subdomains

func (*Subdomains) Add

func (s *Subdomains) Add(name string, e *echo.Echo) *Subdomains

Add 添加子域名,name的值支持以下三种格式: 1. 别名@域名 ———— 一个别名可以对应多个域名,每个域名之间用半角逗号“,”分隔 2. 域名 ———— 可以添加多个域名,每个域名之间用半角逗号“,”分隔。这里会自动将第一个域名中的首个点号“.”前面的部分作为别名,例如“blog.webx.top,news.webx.top”会自动将“blog”作为别名 3. 别名 ———— 在不指定域名的情况下将无法访问,除非“默认访问别名”(Subdomains.Default的值)与此相同

func (*Subdomains) DefaultDispatcher added in v1.4.0

func (s *Subdomains) DefaultDispatcher(r engine.Request, w engine.Response) (*echo.Echo, bool)

func (*Subdomains) FindByDomain

func (s *Subdomains) FindByDomain(host string, upath string) (*echo.Echo, bool)

func (*Subdomains) Get

func (s *Subdomains) Get(args ...string) *Info

func (*Subdomains) Ready added in v1.10.2

func (s *Subdomains) Ready() *Info

func (*Subdomains) RelativeURL added in v1.7.15

func (s *Subdomains) RelativeURL(uri string, args ...string) string

func (*Subdomains) RelativeURLByName added in v1.7.15

func (s *Subdomains) RelativeURLByName(name string, params ...interface{}) string

func (*Subdomains) Run

func (s *Subdomains) Run(args ...interface{})

func (*Subdomains) ServeHTTP

func (s *Subdomains) ServeHTTP(r engine.Request, w engine.Response)

func (*Subdomains) SetDebug added in v1.4.1

func (s *Subdomains) SetDebug(on bool) *Subdomains

func (*Subdomains) SetDispatcher added in v1.4.0

func (s *Subdomains) SetDispatcher(dispatcher Dispatcher) *Subdomains

func (*Subdomains) SortHosts added in v1.10.5

func (s *Subdomains) SortHosts()

func (*Subdomains) URL

func (s *Subdomains) URL(uri string, args ...string) string

URL 多域名场景下的网址生成功能 URL(网址路径,域名别名),如果这里不传递域名别名,将使用默认别名的域名 例如:URL("/list?cid=1","blog") 对于一个别名对应有多个域名的情况,将总是使用第一个域名

func (*Subdomains) URLByName added in v1.6.0

func (s *Subdomains) URLByName(name string, params ...interface{}) string

URLByName 根据路由别名生成网址 可以在名称中采用 #backend#name 的方式来获取子域名别名为bakcend的网址

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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