コード例 #1
0
ファイル: http.go プロジェクト: hank-sunday/nsq
func (s *httpServer) v1Router(w http.ResponseWriter, req *http.Request) error {
	switch req.URL.Path {
	case "/pub":
		http_api.NegotiateVersionWrapper(w, req, http_api.RequirePOST(req,
			func() (interface{}, error) { return s.doPUB(req) }))
	case "/mpub":
		http_api.NegotiateVersionWrapper(w, req, http_api.RequirePOST(req,
			func() (interface{}, error) { return s.doMPUB(req) }))

	case "/stats":
		http_api.NegotiateVersionWrapper(w, req,
			func() (interface{}, error) { return s.doStats(req) })
	case "/ping":
		s.pingHandler(w, req)

	case "/topic/create":
		http_api.V1Wrapper(w, req, http_api.RequirePOST(req,
			func() (interface{}, error) { return s.doCreateTopic(req) }))
	case "/topic/delete":
		http_api.V1Wrapper(w, req, http_api.RequirePOST(req,
			func() (interface{}, error) { return s.doDeleteTopic(req) }))
	case "/topic/empty":
		http_api.V1Wrapper(w, req, http_api.RequirePOST(req,
			func() (interface{}, error) { return s.doEmptyTopic(req) }))
	case "/topic/pause":
		fallthrough
	case "/topic/unpause":
		http_api.V1Wrapper(w, req, http_api.RequirePOST(req,
			func() (interface{}, error) { return s.doPauseTopic(req) }))

	case "/channel/create":
		http_api.V1Wrapper(w, req, http_api.RequirePOST(req,
			func() (interface{}, error) { return s.doCreateChannel(req) }))
	case "/channel/delete":
		http_api.V1Wrapper(w, req, http_api.RequirePOST(req,
			func() (interface{}, error) { return s.doDeleteChannel(req) }))
	case "/channel/empty":
		http_api.V1Wrapper(w, req, http_api.RequirePOST(req,
			func() (interface{}, error) { return s.doEmptyChannel(req) }))
	case "/channel/pause":
		fallthrough
	case "/channel/unpause":
		http_api.V1Wrapper(w, req, http_api.RequirePOST(req,
			func() (interface{}, error) { return s.doPauseChannel(req) }))

	default:
		return fmt.Errorf("404 %s", req.URL.Path)
	}
	return nil
}
コード例 #2
0
ファイル: http.go プロジェクト: zhangyuchen0411/nsq
func (s *httpServer) debugRouter(w http.ResponseWriter, req *http.Request) error {
	switch req.URL.Path {
	case "/debug":
		http_api.NegotiateVersionWrapper(w, req,
			func() (interface{}, error) { return s.doDebug(req) })
	case "/debug/pprof":
		httpprof.Index(w, req)
	case "/debug/pprof/cmdline":
		httpprof.Cmdline(w, req)
	case "/debug/pprof/symbol":
		httpprof.Symbol(w, req)
	case "/debug/pprof/heap":
		httpprof.Handler("heap").ServeHTTP(w, req)
	case "/debug/pprof/goroutine":
		httpprof.Handler("goroutine").ServeHTTP(w, req)
	case "/debug/pprof/profile":
		httpprof.Profile(w, req)
	case "/debug/pprof/block":
		httpprof.Handler("block").ServeHTTP(w, req)
	case "/debug/pprof/threadcreate":
		httpprof.Handler("threadcreate").ServeHTTP(w, req)
	default:
		return fmt.Errorf("404 %s", req.URL.Path)
	}
	return nil
}
コード例 #3
0
ファイル: http.go プロジェクト: zhangyuchen0411/nsq
func (s *httpServer) v1Router(w http.ResponseWriter, req *http.Request) error {
	switch req.URL.Path {
	case "/ping":
		s.pingHandler(w, req)

	case "/lookup":
		http_api.NegotiateVersionWrapper(w, req,
			func() (interface{}, error) { return s.doLookup(req) })
	case "/topics":
		http_api.NegotiateVersionWrapper(w, req,
			func() (interface{}, error) { return s.doTopics(req) })
	case "/channels":
		http_api.NegotiateVersionWrapper(w, req,
			func() (interface{}, error) { return s.doChannels(req) })
	case "/nodes":
		http_api.NegotiateVersionWrapper(w, req,
			func() (interface{}, error) { return s.doNodes(req) })

	case "/topic/create":
		http_api.V1Wrapper(w, req, http_api.RequirePOST(req,
			func() (interface{}, error) { return s.doCreateTopic(req) }))
	case "/topic/delete":
		http_api.V1Wrapper(w, req, http_api.RequirePOST(req,
			func() (interface{}, error) { return s.doDeleteTopic(req) }))
	case "/topic/tombstone":
		http_api.V1Wrapper(w, req, http_api.RequirePOST(req,
			func() (interface{}, error) { return s.doTombstoneTopicProducer(req) }))

	case "/channel/create":
		http_api.V1Wrapper(w, req, http_api.RequirePOST(req,
			func() (interface{}, error) { return s.doCreateChannel(req) }))
	case "/channel/delete":
		http_api.V1Wrapper(w, req, http_api.RequirePOST(req,
			func() (interface{}, error) { return s.doDeleteChannel(req) }))

	default:
		return fmt.Errorf("404 %s", req.URL.Path)
	}
	return nil
}
コード例 #4
0
ファイル: http.go プロジェクト: zhangyuchen0411/nsq
func (s *httpServer) deprecatedRouter(w http.ResponseWriter, req *http.Request) error {
	switch req.URL.Path {
	case "/info":
		http_api.NegotiateVersionWrapper(w, req,
			func() (interface{}, error) { return s.doInfo(req) })
	case "/delete_topic":
		http_api.NegotiateVersionWrapper(w, req,
			func() (interface{}, error) { return s.doDeleteTopic(req) })
	case "/delete_channel":
		http_api.NegotiateVersionWrapper(w, req,
			func() (interface{}, error) { return s.doDeleteChannel(req) })
	case "/tombstone_topic_producer":
		http_api.NegotiateVersionWrapper(w, req,
			func() (interface{}, error) { return s.doTombstoneTopicProducer(req) })
	case "/create_topic":
		http_api.NegotiateVersionWrapper(w, req,
			func() (interface{}, error) { return s.doCreateTopic(req) })
	case "/create_channel":
		http_api.NegotiateVersionWrapper(w, req,
			func() (interface{}, error) { return s.doCreateChannel(req) })
	default:
		return fmt.Errorf("404 %s", req.URL.Path)
	}
	return nil
}
コード例 #5
0
ファイル: http.go プロジェクト: hank-sunday/nsq
func (s *httpServer) deprecatedRouter(w http.ResponseWriter, req *http.Request) error {
	switch req.URL.Path {
	case "/put":
		http_api.NegotiateVersionWrapper(w, req, http_api.RequirePOST(req,
			func() (interface{}, error) { return s.doPUB(req) }))
	case "/mput":
		http_api.NegotiateVersionWrapper(w, req, http_api.RequirePOST(req,
			func() (interface{}, error) { return s.doMPUB(req) }))
	case "/info":
		http_api.NegotiateVersionWrapper(w, req,
			func() (interface{}, error) { return s.doInfo(req) })
	case "/empty_topic":
		http_api.NegotiateVersionWrapper(w, req,
			func() (interface{}, error) { return s.doEmptyTopic(req) })
	case "/delete_topic":
		http_api.NegotiateVersionWrapper(w, req,
			func() (interface{}, error) { return s.doDeleteTopic(req) })
	case "/pause_topic":
		fallthrough
	case "/unpause_topic":
		http_api.NegotiateVersionWrapper(w, req,
			func() (interface{}, error) { return s.doPauseTopic(req) })
	case "/empty_channel":
		http_api.NegotiateVersionWrapper(w, req,
			func() (interface{}, error) { return s.doEmptyChannel(req) })
	case "/delete_channel":
		http_api.NegotiateVersionWrapper(w, req,
			func() (interface{}, error) { return s.doDeleteChannel(req) })
	case "/pause_channel":
		fallthrough
	case "/unpause_channel":
		http_api.NegotiateVersionWrapper(w, req,
			func() (interface{}, error) { return s.doPauseChannel(req) })
	case "/create_topic":
		http_api.NegotiateVersionWrapper(w, req,
			func() (interface{}, error) { return s.doCreateTopic(req) })
	case "/create_channel":
		http_api.NegotiateVersionWrapper(w, req,
			func() (interface{}, error) { return s.doCreateChannel(req) })
	default:
		return fmt.Errorf("404 %s", req.URL.Path)
	}
	return nil
}