Exemple #1
0
func (s *httpServer) v1Router(w http.ResponseWriter, req *http.Request) error {
	switch req.URL.Path {
	case "/pub":
		util.NegotiateAPIResponseWrapper(w, req, util.POSTRequired(req,
			func() (interface{}, error) { return s.doPUB(req) }))
	case "/mpub":
		util.NegotiateAPIResponseWrapper(w, req, util.POSTRequired(req,
			func() (interface{}, error) { return s.doMPUB(req) }))

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

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

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

	default:
		return errors.New(fmt.Sprintf("404 %s", req.URL.Path))
	}
	return nil
}
Exemple #2
0
func (s *httpServer) debugRouter(w http.ResponseWriter, req *http.Request) error {
	switch req.URL.Path {
	case "/debug":
		util.NegotiateAPIResponseWrapper(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 errors.New(fmt.Sprintf("404 %s", req.URL.Path))
	}
	return nil
}
Exemple #3
0
func (s *httpServer) v1Router(w http.ResponseWriter, req *http.Request) error {
	switch req.URL.Path {
	case "/ping":
		s.pingHandler(w, req)

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

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

	case "/channel/create":
		util.V1APIResponseWrapper(w, req, util.POSTRequired(req,
			func() (interface{}, error) { return s.doCreateChannel(req) }))
	case "/channel/delete":
		util.V1APIResponseWrapper(w, req, util.POSTRequired(req,
			func() (interface{}, error) { return s.doDeleteChannel(req) }))

	default:
		return errors.New(fmt.Sprintf("404 %s", req.URL.Path))
	}
	return nil
}
Exemple #4
0
func (s *httpServer) deprecatedRouter(w http.ResponseWriter, req *http.Request) error {
	switch req.URL.Path {
	case "/info":
		util.NegotiateAPIResponseWrapper(w, req,
			func() (interface{}, error) { return s.doInfo(req) })
	case "/delete_topic":
		util.NegotiateAPIResponseWrapper(w, req,
			func() (interface{}, error) { return s.doDeleteTopic(req) })
	case "/delete_channel":
		util.NegotiateAPIResponseWrapper(w, req,
			func() (interface{}, error) { return s.doDeleteChannel(req) })
	case "/tombstone_topic_producer":
		util.NegotiateAPIResponseWrapper(w, req,
			func() (interface{}, error) { return s.doTombstoneTopicProducer(req) })
	case "/create_topic":
		util.NegotiateAPIResponseWrapper(w, req,
			func() (interface{}, error) { return s.doCreateTopic(req) })
	case "/create_channel":
		util.NegotiateAPIResponseWrapper(w, req,
			func() (interface{}, error) { return s.doCreateChannel(req) })
	default:
		return errors.New(fmt.Sprintf("404 %s", req.URL.Path))
	}
	return nil
}
Exemple #5
0
func (s *httpServer) deprecatedRouter(w http.ResponseWriter, req *http.Request) error {
	switch req.URL.Path {
	case "/put":
		util.NegotiateAPIResponseWrapper(w, req, util.POSTRequired(req,
			func() (interface{}, error) { return s.doPUB(req) }))
	case "/mput":
		util.NegotiateAPIResponseWrapper(w, req, util.POSTRequired(req,
			func() (interface{}, error) { return s.doMPUB(req) }))
	case "/info":
		util.NegotiateAPIResponseWrapper(w, req,
			func() (interface{}, error) { return s.doInfo(req) })
	case "/empty_topic":
		util.NegotiateAPIResponseWrapper(w, req,
			func() (interface{}, error) { return s.doEmptyTopic(req) })
	case "/delete_topic":
		util.NegotiateAPIResponseWrapper(w, req,
			func() (interface{}, error) { return s.doDeleteTopic(req) })
	case "/pause_topic":
		fallthrough
	case "/unpause_topic":
		util.NegotiateAPIResponseWrapper(w, req,
			func() (interface{}, error) { return s.doPauseTopic(req) })
	case "/empty_channel":
		util.NegotiateAPIResponseWrapper(w, req,
			func() (interface{}, error) { return s.doEmptyChannel(req) })
	case "/delete_channel":
		util.NegotiateAPIResponseWrapper(w, req,
			func() (interface{}, error) { return s.doDeleteChannel(req) })
	case "/pause_channel":
		fallthrough
	case "/unpause_channel":
		util.NegotiateAPIResponseWrapper(w, req,
			func() (interface{}, error) { return s.doPauseChannel(req) })
	case "/create_topic":
		util.NegotiateAPIResponseWrapper(w, req,
			func() (interface{}, error) { return s.doCreateTopic(req) })
	case "/create_channel":
		util.NegotiateAPIResponseWrapper(w, req,
			func() (interface{}, error) { return s.doCreateChannel(req) })
	default:
		return errors.New(fmt.Sprintf("404 %s", req.URL.Path))
	}
	return nil
}