mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-27 12:28:40 +08:00
30 lines
584 B
Go
30 lines
584 B
Go
package handler
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"shorturl/api/internal/logic"
|
|
"shorturl/api/internal/svc"
|
|
"shorturl/api/internal/types"
|
|
|
|
"github.com/tal-tech/go-zero/rest/httpx"
|
|
)
|
|
|
|
func expandHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
var req types.ExpandReq
|
|
if err := httpx.Parse(r, &req); err != nil {
|
|
httpx.Error(w, err)
|
|
return
|
|
}
|
|
|
|
l := logic.NewExpandLogic(r.Context(), ctx)
|
|
resp, err := l.Expand(req)
|
|
if err != nil {
|
|
httpx.Error(w, err)
|
|
} else {
|
|
httpx.WriteJson(w, http.StatusOK, resp)
|
|
}
|
|
}
|
|
}
|