mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-31 14:13:09 +02:00
refactor(entrypoint): rename shortLinkTree to shortLinkMatcher
This commit is contained in:
@@ -22,7 +22,7 @@ type Entrypoint struct {
|
||||
notFoundHandler http.Handler
|
||||
accessLogger accesslog.AccessLogger
|
||||
findRouteFunc func(host string) types.HTTPRoute
|
||||
shortLinkTree *ShortLinkMatcher
|
||||
shortLinkMatcher *ShortLinkMatcher
|
||||
}
|
||||
|
||||
// nil-safe
|
||||
@@ -36,12 +36,12 @@ func init() {
|
||||
func NewEntrypoint() Entrypoint {
|
||||
return Entrypoint{
|
||||
findRouteFunc: findRouteAnyDomain,
|
||||
shortLinkTree: newShortLinkTree(),
|
||||
shortLinkMatcher: newShortLinkMatcher(),
|
||||
}
|
||||
}
|
||||
|
||||
func (ep *Entrypoint) ShortLinkMatcher() *ShortLinkMatcher {
|
||||
return ep.shortLinkTree
|
||||
return ep.shortLinkMatcher
|
||||
}
|
||||
|
||||
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 ep.middleware != nil {
|
||||
ep.middleware.ServeHTTP(ep.shortLinkTree.ServeHTTP, w, r)
|
||||
ep.middleware.ServeHTTP(ep.shortLinkMatcher.ServeHTTP, w, r)
|
||||
} else {
|
||||
ep.shortLinkTree.ServeHTTP(w, r)
|
||||
ep.shortLinkMatcher.ServeHTTP(w, r)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ type ShortLinkMatcher struct {
|
||||
subdomainRoutes *xsync.Map[string, struct{}]
|
||||
}
|
||||
|
||||
func newShortLinkTree() *ShortLinkMatcher {
|
||||
func newShortLinkMatcher() *ShortLinkMatcher {
|
||||
return &ShortLinkMatcher{
|
||||
fqdnRoutes: xsync.NewMap[string, string](),
|
||||
subdomainRoutes: xsync.NewMap[string, struct{}](),
|
||||
|
||||
Reference in New Issue
Block a user