Allow lookup of IPAM-allocated addresses
This commit is contained in:
1 parent
89074715bc
commit
791584d9f3
3 files changed
+37
-1
No files matched your search
@@ -33,6 +33,15 @@ func (alloc *Allocator) HandleHTTP(router *mux.Router) {
|
||||
w.WriteHeader(204)
|
||||
})
|
||||
|
||||
router.Methods("GET").Path("/ip/{id}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
addr, err := alloc.Lookup(mux.Vars(r)["id"])
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
fmt.Fprintf(w, "%s/%d", addr.String(), alloc.prefixLen)
|
||||
})
|
||||
|
||||
router.Methods("POST").Path("/ip/{id}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
closedChan := w.(http.CloseNotifier).CloseNotify()
|
||||
ident := mux.Vars(r)["id"]
|
||||
|
||||
Reference in new issue
Block a user