router cleanup 1
This commit is contained in:
parent
c0b493b6bc
commit
ec7dcce788
|
@ -2,7 +2,6 @@ package routers
|
||||||
|
|
||||||
import "errors"
|
import "errors"
|
||||||
|
|
||||||
// Common errors
|
|
||||||
var (
|
var (
|
||||||
// ErrRoutesCompilationErrors indicates that some routes failed to compile
|
// ErrRoutesCompilationErrors indicates that some routes failed to compile
|
||||||
// but the router is still operational
|
// but the router is still operational
|
||||||
|
|
|
@ -32,7 +32,7 @@ type Params struct {
|
||||||
|
|
||||||
// Get returns a parameter value by name
|
// Get returns a parameter value by name
|
||||||
func (p *Params) Get(name string) string {
|
func (p *Params) Get(name string) string {
|
||||||
for i := 0; i < p.Count; i++ {
|
for i := range p.Count {
|
||||||
if p.Keys[i] == name {
|
if p.Keys[i] == name {
|
||||||
return p.Values[i]
|
return p.Values[i]
|
||||||
}
|
}
|
||||||
|
@ -211,11 +211,6 @@ func uint64ToBytes(n uint64) []byte {
|
||||||
return b
|
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
|
// getCacheKey generates a cache key for a method and path
|
||||||
func getCacheKey(method, path string) []byte {
|
func getCacheKey(method, path string) []byte {
|
||||||
// Simple concatenation with separator to create a unique key
|
// Simple concatenation with separator to create a unique key
|
||||||
|
|
|
@ -20,7 +20,6 @@ type StaticRouter struct {
|
||||||
urlPrefix string
|
urlPrefix string
|
||||||
rootDir string
|
rootDir string
|
||||||
log bool
|
log bool
|
||||||
// Additional compression options
|
|
||||||
useBrotli bool
|
useBrotli bool
|
||||||
useZstd bool
|
useZstd bool
|
||||||
}
|
}
|
||||||
|
@ -47,11 +46,6 @@ func NewStaticRouter(rootDir string) (*StaticRouter, error) {
|
||||||
CompressedFileSuffix: ".gz",
|
CompressedFileSuffix: ".gz",
|
||||||
CompressBrotli: true,
|
CompressBrotli: true,
|
||||||
CompressZstd: true,
|
CompressZstd: true,
|
||||||
CompressedFileSuffixes: map[string]string{
|
|
||||||
"gzip": ".gz",
|
|
||||||
"br": ".br",
|
|
||||||
"zstd": ".zst",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
r := &StaticRouter{
|
r := &StaticRouter{
|
||||||
|
@ -162,12 +156,6 @@ func (r *StaticRouter) Match(urlPath string) (string, bool) {
|
||||||
return filePath, err == nil
|
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
|
// GetStats returns basic stats about the router
|
||||||
func (r *StaticRouter) GetStats() map[string]any {
|
func (r *StaticRouter) GetStats() map[string]any {
|
||||||
return map[string]any{
|
return map[string]any{
|
||||||
|
@ -179,27 +167,3 @@ func (r *StaticRouter) GetStats() map[string]any {
|
||||||
"cacheTime": r.fs.CacheDuration.String(),
|
"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")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user