Go - Server
package main
import (
"fmt"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request){
//documentwrite
w.Write([]byte("<h1>Hello server</h1>")) //utf-8
fmt.Println(r.Method)//GET; POST: curl -X POST localhost:3000
}
func main(){
//Mux
mux := http.NewServeMux()
//request , callback
mux.HandleFunc("/",handler)//指定該路徑(router)"/", registers此路徑func
//resume
http.ListenAndServe("localhost:3000",mux)
}
Comments
Post a Comment