checkhandler.go 583 B

1234567891011121314151617181920212223242526272829
  1. package handler
  2. import (
  3. "net/http"
  4. "bookstore/api/internal/logic"
  5. "bookstore/api/internal/svc"
  6. "bookstore/api/internal/types"
  7. "github.com/tal-tech/go-zero/rest/httpx"
  8. )
  9. func CheckHandler(ctx *svc.ServiceContext) http.HandlerFunc {
  10. return func(w http.ResponseWriter, r *http.Request) {
  11. var req types.CheckReq
  12. if err := httpx.Parse(r, &req); err != nil {
  13. httpx.Error(w, err)
  14. return
  15. }
  16. l := logic.NewCheckLogic(r.Context(), ctx)
  17. resp, err := l.Check(req)
  18. if err != nil {
  19. httpx.Error(w, err)
  20. } else {
  21. httpx.WriteJson(w, http.StatusOK, resp)
  22. }
  23. }
  24. }