commit be12251fd2dea9505e73dd241f4efb600be8315f Author: Ahmed Sakri Date: Fri Jun 27 11:38:45 2025 +0000 code update recorded at: 27/06/25 11:38:45 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) +}