From ec7dcce788d846c1a0452d5a174a86e5c4d1b9dd Mon Sep 17 00:00:00 2001 From: Sky Johnson Date: Tue, 8 Apr 2025 21:26:52 -0500 Subject: [PATCH] router cleanup 1 --- core/routers/Errors.go | 1 - core/routers/LuaRouter.go | 7 +------ core/routers/StaticRouter.go | 36 ------------------------------------ 3 files changed, 1 insertion(+), 43 deletions(-) diff --git a/core/routers/Errors.go b/core/routers/Errors.go index 24175cb..1b4405b 100644 --- a/core/routers/Errors.go +++ b/core/routers/Errors.go @@ -2,7 +2,6 @@ package routers import "errors" -// Common errors var ( // ErrRoutesCompilationErrors indicates that some routes failed to compile // but the router is still operational diff --git a/core/routers/LuaRouter.go b/core/routers/LuaRouter.go index d2a5737..e74f412 100644 --- a/core/routers/LuaRouter.go +++ b/core/routers/LuaRouter.go @@ -32,7 +32,7 @@ type Params struct { // Get returns a parameter value by name func (p *Params) Get(name string) string { - for i := 0; i < p.Count; i++ { + for i := range p.Count { if p.Keys[i] == name { return p.Values[i] } @@ -211,11 +211,6 @@ func uint64ToBytes(n uint64) []byte { return b } -// bytesToUint64 converts bytes to uint64 -func bytesToUint64(b []byte) uint64 { - return binary.LittleEndian.Uint64(b) -} - // getCacheKey generates a cache key for a method and path func getCacheKey(method, path string) []byte { // Simple concatenation with separator to create a unique key diff --git a/core/routers/StaticRouter.go b/core/routers/StaticRouter.go index 029fcb2..1b7dcc3 100644 --- a/core/routers/StaticRouter.go +++ b/core/routers/StaticRouter.go @@ -20,7 +20,6 @@ type StaticRouter struct { urlPrefix string rootDir string log bool - // Additional compression options useBrotli bool useZstd bool } @@ -47,11 +46,6 @@ func NewStaticRouter(rootDir string) (*StaticRouter, error) { CompressedFileSuffix: ".gz", CompressBrotli: true, CompressZstd: true, - CompressedFileSuffixes: map[string]string{ - "gzip": ".gz", - "br": ".br", - "zstd": ".zst", - }, } r := &StaticRouter{ @@ -162,12 +156,6 @@ func (r *StaticRouter) Match(urlPath string) (string, bool) { return filePath, err == nil } -// Refresh is a no-op in this implementation as there's no cache to refresh -func (r *StaticRouter) Refresh() error { - // No cache to refresh in this implementation - return nil -} - // GetStats returns basic stats about the router func (r *StaticRouter) GetStats() map[string]any { return map[string]any{ @@ -179,27 +167,3 @@ func (r *StaticRouter) GetStats() map[string]any { "cacheTime": r.fs.CacheDuration.String(), } } - -// SetMaxItems is kept for API compatibility with the old router -func (r *StaticRouter) SetMaxItems(n int) { - // No-op in this implementation -} - -// SetMaxItemSize is kept for API compatibility with the old router -func (r *StaticRouter) SetMaxItemSize(n int) { - // No-op in this implementation -} - -// SetTotalCapacity is kept for API compatibility with the old router -func (r *StaticRouter) SetTotalCapacity(n int) { - // No-op in this implementation -} - -// PreloadCommonFiles is kept for API compatibility but is a no-op -// as FastHTTP doesn't have built-in preloading -func (r *StaticRouter) PreloadCommonFiles() { - // No preloading in this implementation - if r.log { - logger.Debug("[StaticRouter] PreloadCommonFiles is a no-op in StaticRouter") - } -}