Rename URL parameter
This commit is contained in:
1 parent
bd7b232663
commit
bae6865e33
1 file changed
+7
-7
+7
-7
@@ -25,13 +25,13 @@ func ListenHttp(domain string, db Zone, port int) {
|
|||||||
io.WriteString(w, "ok")
|
io.WriteString(w, "ok")
|
||||||
})
|
})
|
||||||
|
|
||||||
muxRouter.Methods("PUT").Path("/name/{identifier:.+}/{ip:.+}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
muxRouter.Methods("PUT").Path("/name/{id:.+}/{ip:.+}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
reqError := func(msg string, logmsg string, logargs ...interface{}) {
|
reqError := func(msg string, logmsg string, logargs ...interface{}) {
|
||||||
httpErrorAndLog(Warning, w, msg, http.StatusBadRequest, logmsg, logargs...)
|
httpErrorAndLog(Warning, w, msg, http.StatusBadRequest, logmsg, logargs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
ident := vars["identifier"]
|
idStr := vars["id"]
|
||||||
ipStr := vars["ip"]
|
ipStr := vars["ip"]
|
||||||
name := r.FormValue("fqdn")
|
name := r.FormValue("fqdn")
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ func ListenHttp(domain string, db Zone, port int) {
|
|||||||
|
|
||||||
if dns.IsSubDomain(domain, name) {
|
if dns.IsSubDomain(domain, name) {
|
||||||
Info.Printf("[http] Adding %s -> %s", name, ipStr)
|
Info.Printf("[http] Adding %s -> %s", name, ipStr)
|
||||||
if err := db.AddRecord(ident, name, ip); err != nil {
|
if err := db.AddRecord(idStr, name, ip); err != nil {
|
||||||
if _, ok := err.(DuplicateError); !ok {
|
if _, ok := err.(DuplicateError); !ok {
|
||||||
httpErrorAndLog(
|
httpErrorAndLog(
|
||||||
Error, w, "Internal error", http.StatusInternalServerError,
|
Error, w, "Internal error", http.StatusInternalServerError,
|
||||||
@@ -61,13 +61,13 @@ func ListenHttp(domain string, db Zone, port int) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
muxRouter.Methods("DELETE").Path("/name/{identifier:.+}/{ip:.+}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
muxRouter.Methods("DELETE").Path("/name/{id:.+}/{ip:.+}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
reqError := func(msg string, logmsg string, logargs ...interface{}) {
|
reqError := func(msg string, logmsg string, logargs ...interface{}) {
|
||||||
httpErrorAndLog(Warning, w, msg, http.StatusBadRequest, logmsg, logargs...)
|
httpErrorAndLog(Warning, w, msg, http.StatusBadRequest, logmsg, logargs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
ident := vars["identifier"]
|
idStr := vars["id"]
|
||||||
ipStr := vars["ip"]
|
ipStr := vars["ip"]
|
||||||
|
|
||||||
ip := net.ParseIP(ipStr)
|
ip := net.ParseIP(ipStr)
|
||||||
@@ -75,8 +75,8 @@ func ListenHttp(domain string, db Zone, port int) {
|
|||||||
reqError("Invalid IP in request", "Invalid IP in request: %s", ipStr)
|
reqError("Invalid IP in request", "Invalid IP in request: %s", ipStr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Info.Printf("[http] Deleting %s (%s)", ident, ipStr)
|
Info.Printf("[http] Deleting %s (%s)", idStr, ipStr)
|
||||||
if err := db.DeleteRecord(ident, ip); err != nil {
|
if err := db.DeleteRecord(idStr, ip); err != nil {
|
||||||
if _, ok := err.(LookupError); !ok {
|
if _, ok := err.(LookupError); !ok {
|
||||||
httpErrorAndLog(
|
httpErrorAndLog(
|
||||||
Error, w, "Internal error", http.StatusInternalServerError,
|
Error, w, "Internal error", http.StatusInternalServerError,
|
||||||
|
|||||||
Reference in new issue
Block a user