Ejemplo n.º 1
0
func (s *UnitedAdmin) ServeHTTP(w http.ResponseWriter, req *http.Request) {
	if !utils.AllowMethod(w, req.Method, "HEAD", "GET", "POST", "PUT", "DELETE") {
		return
	}

	if strings.HasPrefix(req.URL.Path, queuePrefixV1) {
		key := req.URL.Path[len(queuePrefixV1):]
		s.queueHandler(w, req, key)
		return
	} else if strings.HasPrefix(req.URL.Path, adminPrefixV1) {
		key := req.URL.Path[len(adminPrefixV1):]
		s.adminHandler(w, req, key)
		return
	} else if strings.HasPrefix(req.URL.Path, pprofPrefixCmd) {
		httpprof.Cmdline(w, req)
		return
	} else if strings.HasPrefix(req.URL.Path, pprofPrefixProfile) {
		httpprof.Profile(w, req)
		return
	} else if strings.HasPrefix(req.URL.Path, pprofPrefixSymbol) {
		httpprof.Symbol(w, req)
		return
	} else if strings.HasPrefix(req.URL.Path, pprofPrefixIndex) {
		httpprof.Index(w, req)
		return
	}

	http.Error(w, "404 Not Found!", http.StatusNotFound)
	return
}
Ejemplo n.º 2
0
// ServeHTTP implements the ServeHTTP interface of HTTPEntry
func (h *HTTPEntry) ServeHTTP(w http.ResponseWriter, req *http.Request) {
	if !utils.AllowMethod(w, req.Method, "HEAD", "GET", "POST", "PUT", "DELETE") {
		return
	}

	if strings.HasPrefix(req.URL.Path, queuePrefixV1) {
		key := req.URL.Path[len(queuePrefixV1):]
		h.queueHandler(w, req, key)
		return
	}

	http.Error(w, "404 Not Found!", http.StatusNotFound)
	return
}