servicehandler.go 582 B

12345678910111213141516171819202122232425262728
  1. package handler
  2. import (
  3. "net/http"
  4. "apklink/service/internal/logic"
  5. "apklink/service/internal/svc"
  6. "apklink/service/internal/types"
  7. "github.com/zeromicro/go-zero/rest/httpx"
  8. )
  9. func ServiceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  10. return func(w http.ResponseWriter, r *http.Request) {
  11. var req types.Request
  12. if err := httpx.Parse(r, &req); err != nil {
  13. httpx.Error(w, err)
  14. return
  15. }
  16. l := logic.NewServiceLogic(r.Context(), svcCtx)
  17. resp, err := l.Service(req)
  18. if err != nil {
  19. httpx.Error(w, err)
  20. } else {
  21. httpx.OkJson(w, resp)
  22. }
  23. }
  24. }