postcommenthandler.go 610 B

12345678910111213141516171819202122232425
  1. package handler
  2. import (
  3. "github.com/zeromicro/go-zero/rest/httpx"
  4. "net/http"
  5. "slow_wild_api/apps/internal/logic"
  6. "slow_wild_api/apps/internal/response"
  7. "slow_wild_api/apps/internal/svc"
  8. "slow_wild_api/apps/internal/types"
  9. )
  10. func postCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  11. return func(w http.ResponseWriter, r *http.Request) {
  12. var req types.PostCommentReq
  13. if err := httpx.Parse(r, &req); err != nil {
  14. httpx.Error(w, err)
  15. return
  16. }
  17. l := logic.NewPostCommentLogic(r.Context(), svcCtx)
  18. resp, err := l.PostComment(&req)
  19. response.Response(w, resp, err) //②
  20. }
  21. }