Rationalize ipam arguments
- rename -defaultsubnet to -ipsubnet - default subnet defaults to whole -iprange - parse and check inside ipam package - removes some error cases
This commit is contained in:
1 parent
f956a76455
commit
3a9af4413d
6 files changed
+67
-77
No files matched your search
@@ -50,10 +50,6 @@ func (alloc *Allocator) HandleHTTP(router *mux.Router) {
|
||||
})
|
||||
|
||||
router.Methods("GET").Path("/ip/{id}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if alloc.defaultSubnet.Blank() {
|
||||
badRequest(w, fmt.Errorf("No subnet specified"))
|
||||
return
|
||||
}
|
||||
addr, err := alloc.Lookup(mux.Vars(r)["id"], alloc.defaultSubnet)
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
@@ -86,10 +82,6 @@ func (alloc *Allocator) HandleHTTP(router *mux.Router) {
|
||||
})
|
||||
|
||||
router.Methods("POST").Path("/ip/{id}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if alloc.defaultSubnet.Blank() {
|
||||
badRequest(w, fmt.Errorf("No subnet specified"))
|
||||
return
|
||||
}
|
||||
closedChan := w.(http.CloseNotifier).CloseNotify()
|
||||
ident := mux.Vars(r)["id"]
|
||||
newAddr, err := alloc.Allocate(ident, alloc.defaultSubnet, closedChan)
|
||||
|
||||
Reference in new issue
Block a user