From 7ff9e52e04da91d5e68db01bd881e375952884db Mon Sep 17 00:00:00 2001 From: Sukhpreet Lohiya Date: Fri, 23 May 2025 07:57:04 +0000 Subject: [PATCH] code update recorded at: 23/05/25 07:57:04 --- handler.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 handler.go diff --git a/handler.go b/handler.go new file mode 100644 index 0000000..4fc45e4 --- /dev/null +++ b/handler.go @@ -0,0 +1,21 @@ +package main + +// Import necessary packages +import ( + "encoding/json" + "net/http" +) + +// Define the handler function +func handler(w http.ResponseWriter, r *http.Request) { + // Initialize a map to hold the response body + response := map[string]string{ + "message": "Hello, World!", // Set the message to "Hello, World!" + } + + // Set the Content-Type header to application/json + w.Header().Set("Content-Type", "application/json") + + // Encode the response map into JSON and write it to the response + json.NewEncoder(w).Encode(response) +}