mirror of
https://github.com/rjNemo/docker_examples
synced 2026-06-06 02:26:45 +00:00
22 lines
451 B
Go
22 lines
451 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
)
|
|
|
|
func main() {
|
|
http.HandleFunc("/", func() http.Handler {
|
|
|
|
type Response struct {
|
|
Message string `json:"message"`
|
|
}
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
response := Response{Message: "pong"}
|
|
json.NewEncoder(w).Encode(response)
|
|
})
|
|
}())
|
|
|
|
http.ListenAndServe(":80", nil) // http://0.0.0.0/
|
|
}
|