MCPcopy Create free account
hub / github.com/dhij/ecomm / getOrder

Method getOrder

ecomm-api/handler/handler.go:155–169  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

153}
154
155func (h *handler) getOrder(w http.ResponseWriter, r *http.Request) {
156 claims := r.Context().Value(authKey{}).(*token.UserClaims)
157
158 order, err := h.client.GetOrder(h.ctx, &pb.OrderReq{
159 UserId: claims.ID,
160 })
161 if err != nil {
162 http.Error(w, "internal server error", http.StatusInternalServerError)
163 return
164 }
165
166 res := toOrderRes(order)
167 w.Header().Set("Content-Type", "application/json")
168 json.NewEncoder(w).Encode(res)
169}
170
171func (h *handler) listOrders(w http.ResponseWriter, r *http.Request) {
172 orders, err := h.client.ListOrders(h.ctx, &pb.OrderReq{})

Callers

nothing calls this directly

Calls 2

toOrderResFunction · 0.85
GetOrderMethod · 0.65

Tested by

no test coverage detected