mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-21 07:51:28 +02:00
refactor(entrypoint): rename shortLinkTree to shortLinkMatcher
This commit is contained in:
@@ -22,7 +22,7 @@ type Entrypoint struct {
|
|||||||
notFoundHandler http.Handler
|
notFoundHandler http.Handler
|
||||||
accessLogger accesslog.AccessLogger
|
accessLogger accesslog.AccessLogger
|
||||||
findRouteFunc func(host string) types.HTTPRoute
|
findRouteFunc func(host string) types.HTTPRoute
|
||||||
shortLinkTree *ShortLinkMatcher
|
shortLinkMatcher *ShortLinkMatcher
|
||||||
}
|
}
|
||||||
|
|
||||||
// nil-safe
|
// nil-safe
|
||||||
@@ -36,12 +36,12 @@ func init() {
|
|||||||
func NewEntrypoint() Entrypoint {
|
func NewEntrypoint() Entrypoint {
|
||||||
return Entrypoint{
|
return Entrypoint{
|
||||||
findRouteFunc: findRouteAnyDomain,
|
findRouteFunc: findRouteAnyDomain,
|
||||||
shortLinkTree: newShortLinkTree(),
|
shortLinkMatcher: newShortLinkMatcher(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ep *Entrypoint) ShortLinkMatcher() *ShortLinkMatcher {
|
func (ep *Entrypoint) ShortLinkMatcher() *ShortLinkMatcher {
|
||||||
return ep.shortLinkTree
|
return ep.shortLinkMatcher
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ep *Entrypoint) SetFindRouteDomains(domains []string) {
|
func (ep *Entrypoint) SetFindRouteDomains(domains []string) {
|
||||||
@@ -130,9 +130,9 @@ func (ep *Entrypoint) tryHandleShortLink(w http.ResponseWriter, r *http.Request)
|
|||||||
}
|
}
|
||||||
if strings.EqualFold(host, common.ShortLinkPrefix) {
|
if strings.EqualFold(host, common.ShortLinkPrefix) {
|
||||||
if ep.middleware != nil {
|
if ep.middleware != nil {
|
||||||
ep.middleware.ServeHTTP(ep.shortLinkTree.ServeHTTP, w, r)
|
ep.middleware.ServeHTTP(ep.shortLinkMatcher.ServeHTTP, w, r)
|
||||||
} else {
|
} else {
|
||||||
ep.shortLinkTree.ServeHTTP(w, r)
|
ep.shortLinkMatcher.ServeHTTP(w, r)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ type ShortLinkMatcher struct {
|
|||||||
subdomainRoutes *xsync.Map[string, struct{}]
|
subdomainRoutes *xsync.Map[string, struct{}]
|
||||||
}
|
}
|
||||||
|
|
||||||
func newShortLinkTree() *ShortLinkMatcher {
|
func newShortLinkMatcher() *ShortLinkMatcher {
|
||||||
return &ShortLinkMatcher{
|
return &ShortLinkMatcher{
|
||||||
fqdnRoutes: xsync.NewMap[string, string](),
|
fqdnRoutes: xsync.NewMap[string, string](),
|
||||||
subdomainRoutes: xsync.NewMap[string, struct{}](),
|
subdomainRoutes: xsync.NewMap[string, struct{}](),
|
||||||
|
|||||||
Reference in New Issue
Block a user