|
- package main
-
- import (
- "biukop.com/sfm/loan"
- log "github.com/sirupsen/logrus"
- "net/http"
- )
-
- func apiV1BrokerList(w http.ResponseWriter, r *http.Request, ss *loan.Session) {
- filter := ""
- keys, ok := r.URL.Query()["filter"]
- if ok && len(keys) >= 1 {
- filter = keys[0]
- }
- data := loan.GetBrokerList(filter)
- apiV1SendJson(data, w, r, ss)
- }
-
- func apiV1BrokerGet(w http.ResponseWriter, r *http.Request, ss *loan.Session) {
- id := r.URL.Path[len(apiV1Prefix+"broker/"):]
- b := loan.Broker{}
- e := b.Read(id)
- if e != nil {
- log.Error("cannot find people by id", id)
- apiV1Client404Error(w, r, ss)
- return
- }
- apiV1SendJson(b, w, r, ss)
- }
|