diff --git a/apiV1LoanSingle.go b/apiV1LoanSingle.go index d4273d9..53e39d8 100644 --- a/apiV1LoanSingle.go +++ b/apiV1LoanSingle.go @@ -47,9 +47,11 @@ func apiV1LoanSinglePostBasic(w http.ResponseWriter, r *http.Request, ss *loan.S l.Amount = input.Amount l.Item = input.Item l.Rating = input.Rating + l.Settlement = input.Settlement l.Description = input.Description e = l.WriteBasic() if e != nil { + log.Error("cannot save basic loan", e.Error()) apiV1Client404Error(w, r, ss) } else { apiV1SendJson(l, w, r, ss) @@ -58,3 +60,17 @@ func apiV1LoanSinglePostBasic(w http.ResponseWriter, r *http.Request, ss *loan.S } } + +func apiV1LoanSingleDelete(w http.ResponseWriter, r *http.Request, ss *loan.Session) { + loanId := r.URL.Path[len(apiV1Prefix+"loan/"):] //remove prefix + + e := loan.Delete(loanId) + if e != nil { + log.Error("cannot delete loan by id ", loanId, e.Error()) + apiV1Client404Error(w, r, ss) + return + } + + apiV1SendJson(loanId, w, r, ss) + +} diff --git a/apiv1.go b/apiv1.go index 7b2d95e..9203167 100644 --- a/apiv1.go +++ b/apiv1.go @@ -37,6 +37,7 @@ func setupApiV1Handler() []apiV1HandlerMap { {"GET", "chart/top-broker", apiV1ChartTopBroker}, {"POST", "grid/loan/full-loan-overview", apiV1GridLoanFullOverview}, {"GET", "loan/", apiV1LoanSingleGet}, + {"DELETE", "loan/", apiV1LoanSingleDelete}, {"GET", "people/", apiV1PeopleGet}, {"GET", "broker/", apiV1BrokerGet}, {"POST", "loan/basic/", apiV1LoanSinglePostBasic}, @@ -59,6 +60,7 @@ func setupApiV1Handler() []apiV1HandlerMap { {"GET", "chart/top-broker", apiV1ChartTopBroker}, {"POST", "grid/loan/full-loan-overview", apiV1GridLoanFullOverview}, {"GET", "loan/", apiV1LoanSingleGet}, + {"DELETE", "loan/", apiV1LoanSingleDelete}, {"GET", "people/", apiV1PeopleGet}, {"GET", "broker/", apiV1BrokerGet}, {"POST", "loan/basic/", apiV1LoanSinglePostBasic},