From a629eb36ea0c7b2a788977a61a952df54bbf4b0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20P=C3=A9rez?= Date: Fri, 30 May 2025 01:18:52 +0200 Subject: [PATCH] add multiply --- main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/main.go b/main.go index b4aff60..94b57ce 100644 --- a/main.go +++ b/main.go @@ -32,6 +32,11 @@ func main() { b, _ := strconv.Atoi(r.URL.Query().Get("b")) json.NewEncoder(w).Encode(map[string]int{"result": sub(a, b)}) }) + mux.HandleFunc("/multiply", func(w http.ResponseWriter, r *http.Request) { + a, _ := strconv.Atoi(r.URL.Query().Get("a")) + b, _ := strconv.Atoi(r.URL.Query().Get("b")) + json.NewEncoder(w).Encode(map[string]int{"result": multiply(a, b)}) + }) http.ListenAndServe(":8080", mux) } @@ -43,3 +48,7 @@ func sum(a, b int) int { func sub(a, b int) int { return a - b } + +func multiply(a, b int) int { + return a * b +}