mirror of
https://github.com/luscis/openlan.git
synced 2025-09-28 21:32:16 +08:00
28 lines
592 B
Go
Executable File
28 lines
592 B
Go
Executable File
package api
|
|
|
|
import (
|
|
"github.com/gorilla/mux"
|
|
"github.com/luscis/openlan/pkg/cache"
|
|
"github.com/luscis/openlan/pkg/models"
|
|
"github.com/luscis/openlan/pkg/schema"
|
|
"net/http"
|
|
)
|
|
|
|
type Neighbor struct {
|
|
}
|
|
|
|
func (h Neighbor) Router(router *mux.Router) {
|
|
router.HandleFunc("/api/neighbor", h.List).Methods("GET")
|
|
}
|
|
|
|
func (h Neighbor) List(w http.ResponseWriter, r *http.Request) {
|
|
neighbors := make([]schema.Neighbor, 0, 1024)
|
|
for n := range cache.Neighbor.List() {
|
|
if n == nil {
|
|
break
|
|
}
|
|
neighbors = append(neighbors, models.NewNeighborSchema(n))
|
|
}
|
|
ResponseJson(w, neighbors)
|
|
}
|