예제 #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 프로젝트: 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
}
예제 #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
}