mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-20 15:31:24 +02:00
refactor(state): replace Entrypoint method with ShortLinkMatcher interface
- Cleaned up agent go.mod by removing unused indirect dependencies.
This commit is contained in:
@@ -140,8 +140,8 @@ func (state *state) EntrypointHandler() http.Handler {
|
||||
return &state.entrypoint
|
||||
}
|
||||
|
||||
func (state *state) Entrypoint() *entrypoint.Entrypoint {
|
||||
return &state.entrypoint
|
||||
func (state *state) ShortLinkMatcher() config.ShortLinkMatcher {
|
||||
return state.entrypoint.ShortLinkMatcher()
|
||||
}
|
||||
|
||||
// AutoCertProvider returns the autocert provider.
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"iter"
|
||||
"net/http"
|
||||
|
||||
"github.com/yusing/godoxy/internal/entrypoint"
|
||||
"github.com/yusing/godoxy/internal/types"
|
||||
"github.com/yusing/goutils/server"
|
||||
"github.com/yusing/goutils/synk"
|
||||
@@ -23,7 +22,7 @@ type State interface {
|
||||
Value() *Config
|
||||
|
||||
EntrypointHandler() http.Handler
|
||||
Entrypoint() *entrypoint.Entrypoint
|
||||
ShortLinkMatcher() ShortLinkMatcher
|
||||
AutoCertProvider() server.CertProvider
|
||||
|
||||
LoadOrStoreProvider(key string, value types.RouteProvider) (actual types.RouteProvider, loaded bool)
|
||||
@@ -35,6 +34,12 @@ type State interface {
|
||||
FlushTmpLog()
|
||||
}
|
||||
|
||||
type ShortLinkMatcher interface {
|
||||
AddRoute(alias string)
|
||||
DelRoute(alias string)
|
||||
ServeHTTP(w http.ResponseWriter, r *http.Request)
|
||||
}
|
||||
|
||||
// could be nil before first call on Load
|
||||
var ActiveState synk.Value[State]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user