This commit is contained in:
Onur Filiz 2016-07-27 12:08:57 -07:00
Родитель ead69a578a
Коммит 045d193ca3
1 изменённых файлов: 34 добавлений и 34 удалений

Просмотреть файл

@ -196,6 +196,40 @@ func (plugin *netPlugin) createEndpoint(w http.ResponseWriter, r *http.Request)
log.Response(plugin.Name, &resp, err)
}
// Handles DeleteEndpoint requests.
func (plugin *netPlugin) deleteEndpoint(w http.ResponseWriter, r *http.Request) {
var req deleteEndpointRequest
// Decode request.
err := plugin.listener.Decode(w, r, &req)
log.Request(plugin.Name, &req, err)
if err != nil {
return
}
// Process request.
plugin.Lock()
defer plugin.Unlock()
nw, err := plugin.nm.getNetwork(req.NetworkID)
if err != nil {
plugin.SendErrorResponse(w, err)
return
}
err = nw.deleteEndpoint(req.EndpointID)
if err != nil {
plugin.SendErrorResponse(w, err)
return
}
// Encode response.
resp := deleteEndpointResponse{}
err = plugin.listener.Encode(w, &resp)
log.Response(plugin.Name, &resp, err)
}
// Handles Join requests.
func (plugin *netPlugin) join(w http.ResponseWriter, r *http.Request) {
var req joinRequest
@ -240,40 +274,6 @@ func (plugin *netPlugin) join(w http.ResponseWriter, r *http.Request) {
log.Response(plugin.Name, &resp, err)
}
// Handles DeleteEndpoint requests.
func (plugin *netPlugin) deleteEndpoint(w http.ResponseWriter, r *http.Request) {
var req deleteEndpointRequest
// Decode request.
err := plugin.listener.Decode(w, r, &req)
log.Request(plugin.Name, &req, err)
if err != nil {
return
}
// Process request.
plugin.Lock()
defer plugin.Unlock()
nw, err := plugin.nm.getNetwork(req.NetworkID)
if err != nil {
plugin.SendErrorResponse(w, err)
return
}
err = nw.deleteEndpoint(req.EndpointID)
if err != nil {
plugin.SendErrorResponse(w, err)
return
}
// Encode response.
resp := deleteEndpointResponse{}
err = plugin.listener.Encode(w, &resp)
log.Response(plugin.Name, &resp, err)
}
// Handles Leave requests.
func (plugin *netPlugin) leave(w http.ResponseWriter, r *http.Request) {
var req leaveRequest