code update recorded at: 23/05/25 07:57:04
This commit is contained in:
commit
7ff9e52e04
|
|
@ -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)
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user