From 34321cd5927772843e46fc66509ff0a8a307056b Mon Sep 17 00:00:00 2001 From: Akhilesh Nayak Date: Wed, 28 Feb 2024 23:17:00 -0800 Subject: [PATCH] fix: minor fixes * Correct delete response header for go example from 'Put' to 'Delete' * Correct Justfile reference to 'frontend/web' to 'web' * Add slices package to replace ftl package that is now internal * Correct json serialization of product pricing from 'priceUSD' to 'priceUsd' --- go/http/http.go | 2 +- online-boutique/Justfile | 2 +- online-boutique/backend/services/checkout/checkout.go | 3 ++- .../backend/services/productcatalog/productcatalog.go | 2 +- online-boutique/backend/slices/slices.go | 9 +++++++++ 5 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 online-boutique/backend/slices/slices.go diff --git a/go/http/http.go b/go/http/http.go index be9cd5ef..16b842ae 100644 --- a/go/http/http.go +++ b/go/http/http.go @@ -102,7 +102,7 @@ type DeleteResponse struct{} //ftl:ingress http DELETE /http/users/{userId} func Delete(ctx context.Context, req builtin.HttpRequest[DeleteRequest]) (builtin.HttpResponse[DeleteResponse, ftl.Unit], error) { return builtin.HttpResponse[DeleteResponse, ftl.Unit]{ - Headers: map[string][]string{"Put": {"Header from FTL"}}, + Headers: map[string][]string{"Delete": {"Header from FTL"}}, Body: ftl.Some(DeleteResponse{}), }, nil } diff --git a/online-boutique/Justfile b/online-boutique/Justfile index a120fc55..65b7958c 100644 --- a/online-boutique/Justfile +++ b/online-boutique/Justfile @@ -4,4 +4,4 @@ dev: # Start the example web frontend for online-boutique web: - cd frontend/web && npm install && npm run dev + cd web && npm install && npm run dev diff --git a/online-boutique/backend/services/checkout/checkout.go b/online-boutique/backend/services/checkout/checkout.go index 0020c68f..49816e46 100644 --- a/online-boutique/backend/services/checkout/checkout.go +++ b/online-boutique/backend/services/checkout/checkout.go @@ -5,6 +5,8 @@ import ( "context" "fmt" + "github.com/TBD54566975/ftl/examples/online-boutique/slices" + "github.com/google/uuid" "ftl/builtin" @@ -14,7 +16,6 @@ import ( "ftl/productcatalog" "ftl/shipping" - "github.com/TBD54566975/ftl/backend/common/slices" "github.com/TBD54566975/ftl/examples/online-boutique/common/money" "github.com/TBD54566975/ftl/go-runtime/ftl" diff --git a/online-boutique/backend/services/productcatalog/productcatalog.go b/online-boutique/backend/services/productcatalog/productcatalog.go index a771ba45..ef7e62b4 100644 --- a/online-boutique/backend/services/productcatalog/productcatalog.go +++ b/online-boutique/backend/services/productcatalog/productcatalog.go @@ -25,7 +25,7 @@ type Product struct { Name string `json:"name"` Description string `json:"description"` Picture string `json:"picture"` - PriceUSD currency.Money `json:"priceUSD"` + PriceUSD currency.Money `json:"priceUsd"` // Categories such as "clothing" or "kitchen" that can be used to look up // other related products. diff --git a/online-boutique/backend/slices/slices.go b/online-boutique/backend/slices/slices.go new file mode 100644 index 00000000..62881bb7 --- /dev/null +++ b/online-boutique/backend/slices/slices.go @@ -0,0 +1,9 @@ +package slices + +func Map[T, U any](slice []T, fn func(T) U) []U { + result := make([]U, len(slice)) + for i, v := range slice { + result[i] = fn(v) + } + return result +}