Commit a3899915 authored by Janos Guljas's avatar Janos Guljas

add jsonhttp.NotFoundHandler and use it in api and debug api

parent 357fcb73
......@@ -18,9 +18,7 @@ import (
func (s *server) setupRouting() {
router := mux.NewRouter()
router.NotFoundHandler = http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
jsonhttp.NotFound(w, nil)
})
router.NotFoundHandler = http.HandlerFunc(jsonhttp.NotFoundHandler)
router.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Ethereum Swarm Bee")
......
......@@ -27,9 +27,7 @@ func (s *server) setupRouting() {
))
router := mux.NewRouter()
router.NotFoundHandler = http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
jsonhttp.NotFound(w, nil)
})
router.NotFoundHandler = http.HandlerFunc(jsonhttp.NotFoundHandler)
router.Handle("/debug/pprof/", http.HandlerFunc(pprof.Index))
router.Handle("/debug/pprof/cmdline", http.HandlerFunc(pprof.Cmdline))
......
......@@ -15,3 +15,7 @@ type MethodHandler map[string]http.Handler
func (h MethodHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
web.HandleMethods(h, `{"message":"Method Not Allowed","code":405}`, DefaultContentTypeHeader, w, r)
}
func NotFoundHandler(w http.ResponseWriter, _ *http.Request) {
NotFound(w, nil)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment