HTTP Servers
JSON Response Text
Many handlers return JSON-shaped text with stable field names.
JSON Response Text
json_response.go
package main
import "fmt"
func main() {
var name =
status := "active"
body := "{\"name\":\"" + name + "\",\"status\":\"" + status + "\"}"
headers := map[string]string{
"Content-Type": "application/json",
}
fmt.Println("name=", name)
fmt.Println("contentType=", headers["Content-Type"])
fmt.Println("body=", body)
}
package main
import "fmt"
func main() {
var name =
status := "active"
body := "{\"name\":\"" + name + "\",\"status\":\"" + status + "\"}"
headers := map[string]string{
"Content-Type": "application/json",
}
fmt.Println("name=", name)
fmt.Println("contentType=", headers["Content-Type"])
fmt.Println("body=", body)
}
package main
import "fmt"
func main() {
var name =
status := "active"
body := "{\"name\":\"" + name + "\",\"status\":\"" + status + "\"}"
headers := map[string]string{
"Content-Type": "application/json",
}
fmt.Println("name=", name)
fmt.Println("contentType=", headers["Content-Type"])
fmt.Println("body=", body)
}
json response
A handler can build a small JSON response body from deterministic values.