This commit is contained in:
Zheng Kai
2023-03-29 17:42:41 +08:00
parent 94b04a181a
commit 1b107ed035
36 changed files with 617 additions and 0 deletions

33
server/src/web/server.go Normal file
View File

@@ -0,0 +1,33 @@
package web
import (
"fmt"
"net/http"
"project/zj"
"time"
)
// Server ...
func Server(port int) {
addr := fmt.Sprintf(`localhost:%d`, port)
mux := http.NewServeMux()
mux.HandleFunc(`/`, failbackHandle)
s := &http.Server{
Addr: addr,
Handler: mux,
ReadTimeout: 30 * time.Second,
WriteTimeout: 30 * time.Second,
IdleTimeout: 30 * time.Second,
}
zj.J(`start web server`, addr)
s.ListenAndServe()
}
func failbackHandle(w http.ResponseWriter, r *http.Request) {
zj.J(`failback handle`, r.URL.String())
}