Commit c176e156 authored by Stefan Dähling's avatar Stefan Dähling
Browse files

fix for ineff assignments

parent ed12c2e1
Pipeline #416932 passed with stages
in 2 minutes and 56 seconds
...@@ -61,106 +61,114 @@ import ( ...@@ -61,106 +61,114 @@ import (
// handleGetAgency is the handler for get requests to path /api/agency // handleGetAgency is the handler for get requests to path /api/agency
func (agency *Agency) handleGetAgency(w http.ResponseWriter, r *http.Request) { func (agency *Agency) handleGetAgency(w http.ResponseWriter, r *http.Request) {
var cmapErr, httpErr error var cmapErr, httpErr error
defer agency.logErrors(r.URL.Path, cmapErr, httpErr)
// return info about agency // return info about agency
var agencyInfo schemas.AgencyInfo var agencyInfo schemas.AgencyInfo
agencyInfo, cmapErr = agency.getAgencyInfo() agencyInfo, cmapErr = agency.getAgencyInfo()
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.CMAPError(w, cmapErr.Error()) httpErr = httpreply.CMAPError(w, cmapErr.Error())
agency.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
httpErr = httpreply.Resource(w, agencyInfo, cmapErr) httpErr = httpreply.Resource(w, agencyInfo, cmapErr)
agency.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
// handlePostAgent is the handler for post requests to path /api/agency/agents // handlePostAgent is the handler for post requests to path /api/agency/agents
func (agency *Agency) handlePostAgent(w http.ResponseWriter, r *http.Request) { func (agency *Agency) handlePostAgent(w http.ResponseWriter, r *http.Request) {
var cmapErr, httpErr error var cmapErr, httpErr error
defer agency.logErrors(r.URL.Path, cmapErr, httpErr)
// create new agent in agency // create new agent in agency
var body []byte var body []byte
body, cmapErr = ioutil.ReadAll(r.Body) body, cmapErr = ioutil.ReadAll(r.Body)
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.InvalidBodyError(w) httpErr = httpreply.InvalidBodyError(w)
agency.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
var agentInfo schemas.AgentInfo var agentInfo schemas.AgentInfo
cmapErr = json.Unmarshal(body, &agentInfo) cmapErr = json.Unmarshal(body, &agentInfo)
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.JSONUnmarshalError(w) httpErr = httpreply.JSONUnmarshalError(w)
agency.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
go agency.createAgent(agentInfo) go agency.createAgent(agentInfo)
httpErr = httpreply.Created(w, nil, "text/plain", []byte("Ressource Created")) httpErr = httpreply.Created(w, nil, "text/plain", []byte("Ressource Created"))
agency.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
// handlePostMsgs is the handler for post requests to path /api/agency/msgs // handlePostMsgs is the handler for post requests to path /api/agency/msgs
func (agency *Agency) handlePostMsgs(w http.ResponseWriter, r *http.Request) { func (agency *Agency) handlePostMsgs(w http.ResponseWriter, r *http.Request) {
var cmapErr, httpErr error var cmapErr, httpErr error
defer agency.logErrors(r.URL.Path, cmapErr, httpErr)
var body []byte var body []byte
body, cmapErr = ioutil.ReadAll(r.Body) body, cmapErr = ioutil.ReadAll(r.Body)
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.InvalidBodyError(w) httpErr = httpreply.InvalidBodyError(w)
agency.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
var msgs []schemas.ACLMessage var msgs []schemas.ACLMessage
cmapErr = json.Unmarshal(body, &msgs) cmapErr = json.Unmarshal(body, &msgs)
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.JSONUnmarshalError(w) httpErr = httpreply.JSONUnmarshalError(w)
agency.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
agency.msgIn <- msgs agency.msgIn <- msgs
httpErr = httpreply.Created(w, cmapErr, "text/plain", []byte("Ressource Created")) httpErr = httpreply.Created(w, cmapErr, "text/plain", []byte("Ressource Created"))
agency.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
// handlePostUndeliverableMsg is the handler for post requests to path /api/agency/msgundeliv // handlePostUndeliverableMsg is the handler for post requests to path /api/agency/msgundeliv
func (agency *Agency) handlePostUndeliverableMsg(w http.ResponseWriter, r *http.Request) { func (agency *Agency) handlePostUndeliverableMsg(w http.ResponseWriter, r *http.Request) {
var cmapErr, httpErr error var cmapErr, httpErr error
defer agency.logErrors(r.URL.Path, cmapErr, httpErr)
var body []byte var body []byte
body, cmapErr = ioutil.ReadAll(r.Body) body, cmapErr = ioutil.ReadAll(r.Body)
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.InvalidBodyError(w) httpErr = httpreply.InvalidBodyError(w)
agency.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
var msg schemas.ACLMessage var msg schemas.ACLMessage
cmapErr = json.Unmarshal(body, &msg) cmapErr = json.Unmarshal(body, &msg)
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.JSONUnmarshalError(w) httpErr = httpreply.JSONUnmarshalError(w)
agency.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
go agency.resendUndeliverableMsg(msg) go agency.resendUndeliverableMsg(msg)
httpErr = httpreply.Created(w, cmapErr, "text/plain", []byte("Ressource Created")) httpErr = httpreply.Created(w, cmapErr, "text/plain", []byte("Ressource Created"))
agency.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
// handleDeleteAgentID is the handler for delete requests to path /api/agency/agents/{agentid} // handleDeleteAgentID is the handler for delete requests to path /api/agency/agents/{agentid}
func (agency *Agency) handleDeleteAgentID(w http.ResponseWriter, r *http.Request) { func (agency *Agency) handleDeleteAgentID(w http.ResponseWriter, r *http.Request) {
var cmapErr, httpErr error var cmapErr, httpErr error
defer agency.logErrors(r.URL.Path, cmapErr, httpErr)
vars := mux.Vars(r) vars := mux.Vars(r)
agentID, cmapErr := strconv.Atoi(vars["agentid"]) agentID, cmapErr := strconv.Atoi(vars["agentid"])
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.NotFoundError(w) httpErr = httpreply.NotFoundError(w)
agency.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
// delete specified agent // delete specified agent
cmapErr = agency.removeAgent(agentID) cmapErr = agency.removeAgent(agentID)
httpErr = httpreply.Deleted(w, cmapErr) httpErr = httpreply.Deleted(w, cmapErr)
agency.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
// handleGetAgentStatus is the handler for get requests to path /api/agency/agents/{agentid}/status // handleGetAgentStatus is the handler for get requests to path /api/agency/agents/{agentid}/status
func (agency *Agency) handleGetAgentStatus(w http.ResponseWriter, r *http.Request) { func (agency *Agency) handleGetAgentStatus(w http.ResponseWriter, r *http.Request) {
var cmapErr, httpErr error var cmapErr, httpErr error
defer agency.logErrors(r.URL.Path, cmapErr, httpErr)
vars := mux.Vars(r) vars := mux.Vars(r)
agentID, cmapErr := strconv.Atoi(vars["agentid"]) agentID, cmapErr := strconv.Atoi(vars["agentid"])
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.NotFoundError(w) httpErr = httpreply.NotFoundError(w)
agency.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
// return status of specified agent // return status of specified agent
...@@ -168,20 +176,22 @@ func (agency *Agency) handleGetAgentStatus(w http.ResponseWriter, r *http.Reques ...@@ -168,20 +176,22 @@ func (agency *Agency) handleGetAgentStatus(w http.ResponseWriter, r *http.Reques
agentStatus, cmapErr = agency.getAgentStatus(agentID) agentStatus, cmapErr = agency.getAgentStatus(agentID)
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.CMAPError(w, cmapErr.Error()) httpErr = httpreply.CMAPError(w, cmapErr.Error())
agency.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
httpErr = httpreply.Resource(w, agentStatus, cmapErr) httpErr = httpreply.Resource(w, agentStatus, cmapErr)
agency.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
// handlePutAgentCustom is the handler for put requests to path /api/agency/agents/{agentid}/custom // handlePutAgentCustom is the handler for put requests to path /api/agency/agents/{agentid}/custom
func (agency *Agency) handlePutAgentCustom(w http.ResponseWriter, r *http.Request) { func (agency *Agency) handlePutAgentCustom(w http.ResponseWriter, r *http.Request) {
var cmapErr, httpErr error var cmapErr, httpErr error
defer agency.logErrors(r.URL.Path, cmapErr, httpErr)
vars := mux.Vars(r) vars := mux.Vars(r)
agentID, cmapErr := strconv.Atoi(vars["agentid"]) agentID, cmapErr := strconv.Atoi(vars["agentid"])
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.NotFoundError(w) httpErr = httpreply.NotFoundError(w)
agency.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
// update custom of specified agent // update custom of specified agent
...@@ -189,15 +199,18 @@ func (agency *Agency) handlePutAgentCustom(w http.ResponseWriter, r *http.Reques ...@@ -189,15 +199,18 @@ func (agency *Agency) handlePutAgentCustom(w http.ResponseWriter, r *http.Reques
body, cmapErr = ioutil.ReadAll(r.Body) body, cmapErr = ioutil.ReadAll(r.Body)
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.InvalidBodyError(w) httpErr = httpreply.InvalidBodyError(w)
agency.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
custom := string(body) custom := string(body)
cmapErr = agency.updateAgentCustom(agentID, custom) cmapErr = agency.updateAgentCustom(agentID, custom)
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.CMAPError(w, cmapErr.Error()) httpErr = httpreply.CMAPError(w, cmapErr.Error())
agency.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
httpErr = httpreply.Updated(w, cmapErr) httpErr = httpreply.Updated(w, cmapErr)
agency.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
......
...@@ -69,66 +69,71 @@ func (ams *AMS) handleAlive(w http.ResponseWriter, r *http.Request) { ...@@ -69,66 +69,71 @@ func (ams *AMS) handleAlive(w http.ResponseWriter, r *http.Request) {
// handleCloneMAP is the handler for requests to path /api/clonemap // handleCloneMAP is the handler for requests to path /api/clonemap
func (ams *AMS) handleCloneMAP(w http.ResponseWriter, r *http.Request) { func (ams *AMS) handleCloneMAP(w http.ResponseWriter, r *http.Request) {
var cmapErr, httpErr error var cmapErr, httpErr error
defer ams.logErrors(r.URL.Path, cmapErr, httpErr)
// return info about running clonemap instance // return info about running clonemap instance
var cmapInfo schemas.CloneMAP var cmapInfo schemas.CloneMAP
cmapInfo, cmapErr = ams.getCloneMAPInfo() cmapInfo, cmapErr = ams.getCloneMAPInfo()
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.CMAPError(w, cmapErr.Error()) httpErr = httpreply.CMAPError(w, cmapErr.Error())
ams.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
httpErr = httpreply.Resource(w, cmapInfo, cmapErr) httpErr = httpreply.Resource(w, cmapInfo, cmapErr)
ams.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
// handleGetMAS is the handler for get requests to path /api/clonemap/mas // handleGetMAS is the handler for get requests to path /api/clonemap/mas
func (ams *AMS) handleGetMAS(w http.ResponseWriter, r *http.Request) { func (ams *AMS) handleGetMAS(w http.ResponseWriter, r *http.Request) {
var cmapErr, httpErr error var cmapErr, httpErr error
defer ams.logErrors(r.URL.Path, cmapErr, httpErr)
var mass []schemas.MASInfoShort var mass []schemas.MASInfoShort
mass, cmapErr = ams.getMASsShort() mass, cmapErr = ams.getMASsShort()
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.CMAPError(w, cmapErr.Error()) httpErr = httpreply.CMAPError(w, cmapErr.Error())
ams.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
httpErr = httpreply.Resource(w, mass, cmapErr) httpErr = httpreply.Resource(w, mass, cmapErr)
ams.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
// handlePostMAS is the handler for post requests to path /api/clonemap/mas // handlePostMAS is the handler for post requests to path /api/clonemap/mas
func (ams *AMS) handlePostMAS(w http.ResponseWriter, r *http.Request) { func (ams *AMS) handlePostMAS(w http.ResponseWriter, r *http.Request) {
var cmapErr, httpErr error var cmapErr, httpErr error
defer ams.logErrors(r.URL.Path, cmapErr, httpErr)
// create new MAS // create new MAS
var body []byte var body []byte
body, cmapErr = ioutil.ReadAll(r.Body) body, cmapErr = ioutil.ReadAll(r.Body)
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.InvalidBodyError(w) httpErr = httpreply.InvalidBodyError(w)
ams.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
var masSpec schemas.MASSpec var masSpec schemas.MASSpec
cmapErr = json.Unmarshal(body, &masSpec) cmapErr = json.Unmarshal(body, &masSpec)
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.JSONUnmarshalError(w) httpErr = httpreply.JSONUnmarshalError(w)
ams.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
cmapErr = ams.createMAS(masSpec) cmapErr = ams.createMAS(masSpec)
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.CMAPError(w, cmapErr.Error()) httpErr = httpreply.CMAPError(w, cmapErr.Error())
ams.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
httpErr = httpreply.Created(w, cmapErr, "text/plain", []byte("Ressource Created")) httpErr = httpreply.Created(w, cmapErr, "text/plain", []byte("Ressource Created"))
ams.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
// handleGetMASID is the handler for get requests to path /api/clonemap/mas/{masid} // handleGetMASID is the handler for get requests to path /api/clonemap/mas/{masid}
func (ams *AMS) handleGetMASID(w http.ResponseWriter, r *http.Request) { func (ams *AMS) handleGetMASID(w http.ResponseWriter, r *http.Request) {
var cmapErr, httpErr error var cmapErr, httpErr error
defer ams.logErrors(r.URL.Path, cmapErr, httpErr)
vars := mux.Vars(r) vars := mux.Vars(r)
masID, cmapErr := strconv.Atoi(vars["masid"]) masID, cmapErr := strconv.Atoi(vars["masid"])
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.NotFoundError(w) httpErr = httpreply.NotFoundError(w)
ams.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
// return long information about specified MAS // return long information about specified MAS
...@@ -136,36 +141,39 @@ func (ams *AMS) handleGetMASID(w http.ResponseWriter, r *http.Request) { ...@@ -136,36 +141,39 @@ func (ams *AMS) handleGetMASID(w http.ResponseWriter, r *http.Request) {
masInfo, cmapErr = ams.getMASInfo(masID) masInfo, cmapErr = ams.getMASInfo(masID)
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.CMAPError(w, cmapErr.Error()) httpErr = httpreply.CMAPError(w, cmapErr.Error())
ams.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
httpErr = httpreply.Resource(w, masInfo, cmapErr) httpErr = httpreply.Resource(w, masInfo, cmapErr)
ams.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
// handleDeleteMASID is the handler for delete requests to path /api/clonemap/mas/{masid} // handleDeleteMASID is the handler for delete requests to path /api/clonemap/mas/{masid}
func (ams *AMS) handleDeleteMASID(w http.ResponseWriter, r *http.Request) { func (ams *AMS) handleDeleteMASID(w http.ResponseWriter, r *http.Request) {
var cmapErr, httpErr error var cmapErr, httpErr error
defer ams.logErrors(r.URL.Path, cmapErr, httpErr)
vars := mux.Vars(r) vars := mux.Vars(r)
masID, cmapErr := strconv.Atoi(vars["masid"]) masID, cmapErr := strconv.Atoi(vars["masid"])
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.NotFoundError(w) httpErr = httpreply.NotFoundError(w)
ams.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
// delete specified MAS // delete specified MAS
cmapErr = ams.removeMAS(masID) cmapErr = ams.removeMAS(masID)
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.CMAPError(w, cmapErr.Error()) httpErr = httpreply.CMAPError(w, cmapErr.Error())
ams.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
httpErr = httpreply.Deleted(w, cmapErr) httpErr = httpreply.Deleted(w, cmapErr)
ams.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
// handleGetMASName is the handler for get requests to path /api/clonemap/mas/name/{name} // handleGetMASName is the handler for get requests to path /api/clonemap/mas/name/{name}
func (ams *AMS) handleGetMASName(w http.ResponseWriter, r *http.Request) { func (ams *AMS) handleGetMASName(w http.ResponseWriter, r *http.Request) {
var cmapErr, httpErr error var cmapErr, httpErr error
defer ams.logErrors(r.URL.Path, cmapErr, httpErr)
vars := mux.Vars(r) vars := mux.Vars(r)
name := vars["name"] name := vars["name"]
// search for MAS with matching name // search for MAS with matching name
...@@ -173,20 +181,22 @@ func (ams *AMS) handleGetMASName(w http.ResponseWriter, r *http.Request) { ...@@ -173,20 +181,22 @@ func (ams *AMS) handleGetMASName(w http.ResponseWriter, r *http.Request) {
ids, cmapErr = ams.getMASByName(name) ids, cmapErr = ams.getMASByName(name)
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.CMAPError(w, cmapErr.Error()) httpErr = httpreply.CMAPError(w, cmapErr.Error())
ams.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
httpErr = httpreply.Resource(w, ids, cmapErr) httpErr = httpreply.Resource(w, ids, cmapErr)
ams.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
// handleGetAgents is the handler for get requests to path /api/clonemap/mas/{masid}/agents // handleGetAgents is the handler for get requests to path /api/clonemap/mas/{masid}/agents
func (ams *AMS) handleGetAgents(w http.ResponseWriter, r *http.Request) { func (ams *AMS) handleGetAgents(w http.ResponseWriter, r *http.Request) {
var cmapErr, httpErr error var cmapErr, httpErr error
defer ams.logErrors(r.URL.Path, cmapErr, httpErr)
vars := mux.Vars(r) vars := mux.Vars(r)
masID, cmapErr := strconv.Atoi(vars["masid"]) masID, cmapErr := strconv.Atoi(vars["masid"])
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.NotFoundError(w) httpErr = httpreply.NotFoundError(w)
ams.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
// return short information of all agents in specified MAS // return short information of all agents in specified MAS
...@@ -194,20 +204,22 @@ func (ams *AMS) handleGetAgents(w http.ResponseWriter, r *http.Request) { ...@@ -194,20 +204,22 @@ func (ams *AMS) handleGetAgents(w http.ResponseWriter, r *http.Request) {
agents, cmapErr = ams.getAgents(masID) agents, cmapErr = ams.getAgents(masID)
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.CMAPError(w, cmapErr.Error()) httpErr = httpreply.CMAPError(w, cmapErr.Error())
ams.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
httpErr = httpreply.Resource(w, agents, cmapErr) httpErr = httpreply.Resource(w, agents, cmapErr)
ams.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
// handlePostAgent is the handler for post requests to path /api/clonemap/mas/{masid}/agents // handlePostAgent is the handler for post requests to path /api/clonemap/mas/{masid}/agents
func (ams *AMS) handlePostAgent(w http.ResponseWriter, r *http.Request) { func (ams *AMS) handlePostAgent(w http.ResponseWriter, r *http.Request) {
var cmapErr, httpErr error var cmapErr, httpErr error
defer ams.logErrors(r.URL.Path, cmapErr, httpErr)
vars := mux.Vars(r) vars := mux.Vars(r)
masID, cmapErr := strconv.Atoi(vars["masid"]) masID, cmapErr := strconv.Atoi(vars["masid"])
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.NotFoundError(w) httpErr = httpreply.NotFoundError(w)
ams.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
// create new agent in MAS // create new agent in MAS
...@@ -215,20 +227,24 @@ func (ams *AMS) handlePostAgent(w http.ResponseWriter, r *http.Request) { ...@@ -215,20 +227,24 @@ func (ams *AMS) handlePostAgent(w http.ResponseWriter, r *http.Request) {
body, cmapErr = ioutil.ReadAll(r.Body) body, cmapErr = ioutil.ReadAll(r.Body)
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.InvalidBodyError(w) httpErr = httpreply.InvalidBodyError(w)
ams.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
var imgroupSpecs []schemas.ImageGroupSpec var imgroupSpecs []schemas.ImageGroupSpec
cmapErr = json.Unmarshal(body, &imgroupSpecs) cmapErr = json.Unmarshal(body, &imgroupSpecs)
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.JSONUnmarshalError(w) httpErr = httpreply.JSONUnmarshalError(w)
ams.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
cmapErr = ams.createAgents(masID, imgroupSpecs) cmapErr = ams.createAgents(masID, imgroupSpecs)
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.CMAPError(w, cmapErr.Error()) httpErr = httpreply.CMAPError(w, cmapErr.Error())
ams.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
httpErr = httpreply.Created(w, cmapErr, "text/plain", []byte("Ressource Created")) httpErr = httpreply.Created(w, cmapErr, "text/plain", []byte("Ressource Created"))
ams.logErrors(r.URL.Path, cmapErr, httpErr)
return return
} }
...@@ -236,19 +252,21 @@ func (ams *AMS) handlePostAgent(w http.ResponseWriter, r *http.Request) { ...@@ -236,19 +252,21 @@ func (ams *AMS) handlePostAgent(w http.ResponseWriter, r *http.Request) {
// /api/clonemap/mas/{masid}/agents/{agentid} // /api/clonemap/mas/{masid}/agents/{agentid}
func (ams *AMS) handleGetAgentID(w http.ResponseWriter, r *http.Request) { func (ams *AMS) handleGetAgentID(w http.ResponseWriter, r *http.Request) {
var cmapErr, httpErr error var cmapErr, httpErr error
defer ams.logErrors(r.URL.Path, cmapErr, httpErr)
masID, agentID, cmapErr := getAgentID(r) masID, agentID, cmapErr := getAgentID(r)
if cmapErr != nil { if cmapErr != nil {
httpErr = httpreply.NotFoundError(w) httpErr = httpreply.NotFoundError(w)
</