mirror of
https://github.com/luscis/openlan.git
synced 2025-10-01 23:02:22 +08:00
28 lines
558 B
Go
Executable File
28 lines
558 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 OnLine struct {
|
|
}
|
|
|
|
func (h OnLine) Router(router *mux.Router) {
|
|
router.HandleFunc("/api/online", h.List).Methods("GET")
|
|
}
|
|
|
|
func (h OnLine) List(w http.ResponseWriter, r *http.Request) {
|
|
nets := make([]schema.OnLine, 0, 1024)
|
|
for u := range cache.Online.List() {
|
|
if u == nil {
|
|
break
|
|
}
|
|
nets = append(nets, models.NewOnLineSchema(u))
|
|
}
|
|
ResponseJson(w, nets)
|
|
}
|