mirror of
https://github.com/zhengkai/orca.git
synced 2026-02-10 22:32:25 +08:00
up
This commit is contained in:
33
server/src/web/server.go
Normal file
33
server/src/web/server.go
Normal 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())
|
||||
}
|
||||
Reference in New Issue
Block a user