mirror of
https://github.com/Websoft9/websoft9.git
synced 2025-01-24 10:17:15 +08:00
26 lines
541 B
Go
26 lines
541 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"log"
|
||
|
"net/http"
|
||
|
"net/http/httputil"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
http.HandleFunc("/", handleRequest)
|
||
|
log.Fatal(http.ListenAndServe(":8080", nil))
|
||
|
}
|
||
|
|
||
|
func handleRequest(w http.ResponseWriter, r *http.Request) {
|
||
|
// 打印请求行和头部信息
|
||
|
requestDump, err := httputil.DumpRequest(r, true)
|
||
|
if err != nil {
|
||
|
log.Println("Error dumping request:", err)
|
||
|
return
|
||
|
}
|
||
|
log.Println(string(requestDump))
|
||
|
|
||
|
log.Println("-----------------------接口被调用了一次!---------")
|
||
|
fmt.Fprintf(w, "--Hello, World!")
|
||
|
}
|