You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
643B

  1. package main
  2. import (
  3. "biukop.com/sfm/loan"
  4. log "github.com/sirupsen/logrus"
  5. "net/http"
  6. )
  7. func apiV1PeopleList(w http.ResponseWriter, r *http.Request, ss *loan.Session) {
  8. filter := ""
  9. keys, ok := r.URL.Query()["filter"]
  10. if ok && len(keys) >= 1 {
  11. filter = keys[0]
  12. }
  13. data := loan.GetPeopleList(filter)
  14. apiV1SendJson(data, w, r, ss)
  15. }
  16. func apiV1PeopleGet(w http.ResponseWriter, r *http.Request, ss *loan.Session) {
  17. id := r.URL.Path[len(apiV1Prefix+"people/"):]
  18. p := loan.People{}
  19. e := p.Read(id)
  20. if e != nil {
  21. log.Error("cannot find people by id", id)
  22. apiV1Client404Error(w, r, ss)
  23. return
  24. }
  25. apiV1SendJson(p, w, r, ss)
  26. }