package mux import ( "fmt" "log/slog" "sync" ) type RouteList struct { mu sync.RWMutex routes []string } func (s *RouteList) Add(item string) { if s == nil { slog.Warn("failed on Add, RouteList is nil") return } s.mu.Lock() defer s.mu.Unlock() s.routes = append(s.routes, item) } func (s *RouteList) Get(index int) (string, error) { if s == nil { slog.Warn("failed on Get, RouteList is nil") return "", nil } s.mu.RLock() defer s.mu.RUnlock() if index < 0 || index >= len(s.routes) { return "0", fmt.Errorf("index out of bounds") } return s.routes[index], nil } func (s *RouteList) All() []string { if s == nil { slog.Warn("failed on All, RouteList is nil") return nil } s.mu.RLock() defer s.mu.RUnlock() return s.routes }