Files
Blog/app/internal/handler/listpostshandler.go
cialloo 85794f13a4
All checks were successful
CI - Build and Push / Build and Push Docker Image (push) Successful in 52s
update
2025-10-25 12:09:12 +08:00

30 lines
730 B
Go

package handler
import (
"net/http"
"git.cialloo.com/CiallooWeb/Blog/app/internal/logic"
"git.cialloo.com/CiallooWeb/Blog/app/internal/svc"
"git.cialloo.com/CiallooWeb/Blog/app/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)
// Get a list of blog posts
func ListPostsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ListPostsReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := logic.NewListPostsLogic(r.Context(), svcCtx)
resp, err := l.ListPosts(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}