go语言实现http服务器

package main

import (
	"log"
	"net/http"
)

func helthz(w http.ResponseWriter, r *http.Request) {
	if len(r.Header) > 0 {
		for k, v := range r.Header {
			w.Write([]byte(k))
			w.Write([]byte(v[0]))
		}
	}
}

func main() {
	http.HandleFunc("/", helthz)
	err := http.ListenAndServe(":80", nil)
	if err != nil {
		log.Fatal(err)
	}
}

你可能感兴趣的:(个人mark,golang,开发语言,后端)