mirror of
https://github.com/luscis/openlan.git
synced 2025-09-28 13:22:15 +08:00
28 lines
557 B
Go
Executable File
28 lines
557 B
Go
Executable File
package api
|
|
|
|
import (
|
|
"github.com/gorilla/mux"
|
|
"github.com/luscis/openlan/pkg/cache"
|
|
"github.com/luscis/openlan/pkg/schema"
|
|
"net/http"
|
|
)
|
|
|
|
type Lease struct {
|
|
}
|
|
|
|
func (l Lease) Router(router *mux.Router) {
|
|
router.HandleFunc("/api/lease", l.List).Methods("GET")
|
|
router.HandleFunc("/api/lease/{id}", l.List).Methods("GET")
|
|
}
|
|
|
|
func (l Lease) List(w http.ResponseWriter, r *http.Request) {
|
|
nets := make([]schema.Lease, 0, 1024)
|
|
for u := range cache.Network.ListLease() {
|
|
if u == nil {
|
|
break
|
|
}
|
|
nets = append(nets, *u)
|
|
}
|
|
ResponseJson(w, nets)
|
|
}
|