manually fix json casing
All checks were successful
Build and Publish / BuildAndDeployAmd64 (push) Successful in 27s
Build and Publish / BuildAndDeploy (push) Successful in 2m25s

This commit is contained in:
matst80
2024-11-14 20:19:02 +01:00
parent 9a80d74325
commit 352c570f0b
2 changed files with 52 additions and 33 deletions

View File

@@ -179,10 +179,29 @@ func (s *PoolServer) HandleQuantityChange(w http.ResponseWriter, r *http.Request
return s.WriteResult(w, reply)
}
func (s *PoolServer) HandleAddRequest(w http.ResponseWriter, r *http.Request) error {
id := r.PathValue("id")
pickupPoint := messages.AddRequest{}
err := json.NewDecoder(r.Body).Decode(&pickupPoint)
if err != nil {
return err
}
reply, err := s.pool.Process(ToCartId(id), Message{
Type: AddRequestType,
Content: &pickupPoint,
})
if err != nil {
return err
}
return s.WriteResult(w, reply)
}
func (s *PoolServer) Serve() *http.ServeMux {
mux := http.NewServeMux()
mux.HandleFunc("GET /{id}", ErrorHandler(s.HandleGet))
mux.HandleFunc("GET /{id}/add/{sku}", ErrorHandler(s.HandleAddSku))
mux.HandleFunc("POST /{id}", ErrorHandler(s.HandleAddRequest))
mux.HandleFunc("DELETE /{id}/{itemId}", ErrorHandler(s.HandleDeleteItem))
mux.HandleFunc("PUT /{id}/{itemId}", ErrorHandler(s.HandleQuantityChange))
mux.HandleFunc("POST /{id}/delivery", ErrorHandler(s.HandleSetDelivery))