Compare commits
No commits in common. "894dbc1bbf5c4e7ef6eae0503029cc016f64d322" and "6cae096a9b6ec023d9628c93f59b4c55ddfb7acb" have entirely different histories.
894dbc1bbf
...
6cae096a9b
14
README.md
14
README.md
|
@ -1,6 +1,6 @@
|
|||
# ksrv
|
||||
# kmux
|
||||
|
||||
A extended http.Server with logging and panic recovery
|
||||
A extended gorilla mux with logging and panic recovery
|
||||
|
||||
## Examples
|
||||
|
||||
|
@ -13,22 +13,20 @@ import (
|
|||
"net/http"
|
||||
|
||||
"kumoly.io/core/log"
|
||||
"kumoly.io/lib/ksrv"
|
||||
"kumoly.io/lib/kmux"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.PROD = false
|
||||
mux := http.NewServeMux()
|
||||
mux := kmux.NewRouter()
|
||||
mux.HandleFunc("/", func(rw http.ResponseWriter, r *http.Request) { rw.Write([]byte("ok")) })
|
||||
mux.HandleFunc("/err", func(rw http.ResponseWriter, r *http.Request) { ksrv.Abort(rw, errors.New("small err")) })
|
||||
mux.HandleFunc("/err", func(rw http.ResponseWriter, r *http.Request) { kmux.Abort(rw, errors.New("small err")) })
|
||||
mux.HandleFunc("/panic", func(rw http.ResponseWriter, r *http.Request) { panic(500) })
|
||||
mux.HandleFunc("/out", func(rw http.ResponseWriter, r *http.Request) { arr := []int{0, 1}; fmt.Print(arr[9]) })
|
||||
log.Info("start")
|
||||
|
||||
err := ksrv.New().Listen("0.0.0.0:8080").Serve()
|
||||
err := mux.Server().Listen("0.0.0.0:8081").Serve()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
```
|
|
@ -18,7 +18,7 @@ func main() {
|
|||
mux.HandleFunc("/out", func(rw http.ResponseWriter, r *http.Request) { arr := []int{0, 1}; fmt.Print(arr[9]) })
|
||||
log.Info("start")
|
||||
|
||||
err := ksrv.New().Listen("0.0.0.0:8080").Serve()
|
||||
err := ksrv.New().Listen("0.0.0.0:8081").Serve()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue