當前位置: 首頁>>代碼示例>>Golang>>正文


Golang util.LogHandlerExitWithJSON函數代碼示例

本文整理匯總了Golang中github.com/kubernetes/deployment-manager/util.LogHandlerExitWithJSON函數的典型用法代碼示例。如果您正苦於以下問題:Golang LogHandlerExitWithJSON函數的具體用法?Golang LogHandlerExitWithJSON怎麽用?Golang LogHandlerExitWithJSON使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了LogHandlerExitWithJSON函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: createRegistryHandlerFunc

func createRegistryHandlerFunc(w http.ResponseWriter, r *http.Request) {
	handler := "manager: create registry"
	util.LogHandlerEntry(handler, r)
	defer r.Body.Close()
	registryName, err := getPathVariable(w, r, "registry", handler)
	if err != nil {
		return
	}

	reg := getRegistry(w, r, handler)
	if reg.Name != registryName {
		e := fmt.Errorf("Registry name does not match %s != %s", reg.Name, registryName)
		util.LogAndReturnError(handler, http.StatusBadRequest, e, w)
		return
	}
	if reg != nil {
		err = backend.CreateRegistry(reg)
		if err != nil {
			util.LogAndReturnError(handler, http.StatusBadRequest, err, w)
			return
		}
	}

	util.LogHandlerExitWithJSON(handler, w, reg, http.StatusOK)
}
開發者ID:huhoo,項目名稱:deployment-manager,代碼行數:25,代碼來源:deployments.go

示例2: listRegistryTypesHandlerFunc

func listRegistryTypesHandlerFunc(w http.ResponseWriter, r *http.Request) {
	handler := "manager: list registry types"
	util.LogHandlerEntry(handler, r)
	registryName, err := getPathVariable(w, r, "registry", handler)
	if err != nil {
		return
	}

	var regex *regexp.Regexp
	regexString, err := getPathVariable(w, r, "regex", handler)
	if err == nil {
		regex, err = regexp.Compile(regexString)
		if err != nil {
			util.LogAndReturnError(handler, http.StatusInternalServerError, err, w)
			return
		}
	}

	registryTypes, err := backend.ListRegistryTypes(registryName, regex)
	if err != nil {
		util.LogAndReturnError(handler, http.StatusInternalServerError, err, w)
		return
	}

	util.LogHandlerExitWithJSON(handler, w, registryTypes, http.StatusOK)
}
開發者ID:shawnps,項目名稱:deployment-manager,代碼行數:26,代碼來源:deployments.go

示例3: roundTripHandler

func roundTripHandler(w http.ResponseWriter, r *http.Request) {
	defer r.Body.Close()
	handler := "expandybird: expand"
	util.LogHandlerEntry(handler, r)
	util.LogHandlerExitWithJSON(handler, w, roundTripResponses[0], http.StatusOK)
	roundTripResponses = roundTripResponses[1:]
}
開發者ID:RamessesYin,項目名稱:deployment-manager,代碼行數:7,代碼來源:expander_test.go

示例4: getDownloadURLsHandlerFunc

func getDownloadURLsHandlerFunc(w http.ResponseWriter, r *http.Request) {
	handler := "manager: get download URLs"
	util.LogHandlerEntry(handler, r)
	registryName, err := getPathVariable(w, r, "registry", handler)
	if err != nil {
		return
	}

	typeName, err := getPathVariable(w, r, "type", handler)
	if err != nil {
		return
	}

	tt, err := registry.ParseType(typeName)
	if err != nil {
		util.LogAndReturnError(handler, http.StatusInternalServerError, err, w)
		return
	}

	c, err := backend.GetDownloadURLs(registryName, tt)
	if err != nil {
		util.LogAndReturnError(handler, http.StatusBadRequest, err, w)
		return
	}

	urls := []string{}
	for _, u := range c {
		urls = append(urls, u.String())
	}
	util.LogHandlerExitWithJSON(handler, w, urls, http.StatusOK)
}
開發者ID:shawnps,項目名稱:deployment-manager,代碼行數:31,代碼來源:deployments.go

示例5: expanderSuccessHandler

func expanderSuccessHandler(w http.ResponseWriter, r *http.Request) {
	handler := "expandybird: expand"
	util.LogHandlerEntry(handler, r)
	defer r.Body.Close()
	body, err := ioutil.ReadAll(r.Body)
	if err != nil {
		status := fmt.Sprintf("cannot read request body:%s", err)
		http.Error(w, status, http.StatusInternalServerError)
		return
	}

	template := &Template{}
	if err := json.Unmarshal(body, template); err != nil {
		status := fmt.Sprintf("cannot unmarshal request body:%s\n%s\n", err, body)
		http.Error(w, status, http.StatusInternalServerError)
		return
	}

	if !reflect.DeepEqual(validTemplateTestCaseData, *template) {
		status := fmt.Sprintf("error in http handler:\nwant:%s\nhave:%s\n",
			util.ToJSONOrError(validTemplateTestCaseData), util.ToJSONOrError(template))
		http.Error(w, status, http.StatusInternalServerError)
		return
	}

	util.LogHandlerExitWithJSON(handler, w, validResponseTestCaseData, http.StatusOK)
}
開發者ID:RamessesYin,項目名稱:deployment-manager,代碼行數:27,代碼來源:expander_test.go

示例6: listRegistriesHandlerFunc

// Putting Registry handlers here for now because deployments.go
// currently owns its own Manager backend and doesn't like to share.
func listRegistriesHandlerFunc(w http.ResponseWriter, r *http.Request) {
	handler := "manager: list registries"
	util.LogHandlerEntry(handler, r)
	registries, err := backend.ListRegistries()
	if err != nil {
		return
	}

	util.LogHandlerExitWithJSON(handler, w, registries, http.StatusOK)
}
開發者ID:shawnps,項目名稱:deployment-manager,代碼行數:12,代碼來源:deployments.go

示例7: listTypeInstancesHandlerFunc

func listTypeInstancesHandlerFunc(w http.ResponseWriter, r *http.Request) {
	handler := "manager: list instances"
	util.LogHandlerEntry(handler, r)
	typeName, err := getPathVariable(w, r, "type", handler)
	if err != nil {
		return
	}

	util.LogHandlerExitWithJSON(handler, w, backend.ListInstances(typeName), http.StatusOK)
}
開發者ID:RamessesYin,項目名稱:deployment-manager,代碼行數:10,代碼來源:deployments.go

示例8: listTypesHandlerFunc

// Putting Type handlers here for now because deployments.go
// currently owns its own Manager backend and doesn't like to share.
func listTypesHandlerFunc(w http.ResponseWriter, r *http.Request) {
	handler := "manager: list types"
	util.LogHandlerEntry(handler, r)
	types, err := backend.ListTypes()
	if err != nil {
		util.LogAndReturnError(handler, http.StatusBadRequest, err, w)
		return
	}

	util.LogHandlerExitWithJSON(handler, w, types, http.StatusOK)
}
開發者ID:huhoo,項目名稱:deployment-manager,代碼行數:13,代碼來源:deployments.go

示例9: listDeploymentsHandlerFunc

func listDeploymentsHandlerFunc(w http.ResponseWriter, r *http.Request) {
	handler := "manager: list deployments"
	util.LogHandlerEntry(handler, r)
	l, err := backend.ListDeployments()
	if err != nil {
		util.LogAndReturnError(handler, http.StatusInternalServerError, err, w)
		return
	}
	var names []string
	for _, d := range l {
		names = append(names, d.Name)
	}

	util.LogHandlerExitWithJSON(handler, w, names, http.StatusOK)
}
開發者ID:RamessesYin,項目名稱:deployment-manager,代碼行數:15,代碼來源:deployments.go

示例10: getCredentialHandlerFunc

func getCredentialHandlerFunc(w http.ResponseWriter, r *http.Request) {
	handler := "manager: get credential"
	util.LogHandlerEntry(handler, r)
	credentialName, err := getPathVariable(w, r, "credential", handler)
	if err != nil {
		return
	}

	c, err := backend.GetCredential(credentialName)
	if err != nil {
		util.LogAndReturnError(handler, http.StatusBadRequest, err, w)
		return
	}

	util.LogHandlerExitWithJSON(handler, w, c, http.StatusOK)
}
開發者ID:shawnps,項目名稱:deployment-manager,代碼行數:16,代碼來源:deployments.go

示例11: expandHandlerFunc

func expandHandlerFunc(w http.ResponseWriter, r *http.Request) {
	handler := "manager: expand config"
	util.LogHandlerEntry(handler, r)
	defer r.Body.Close()
	t := getTemplate(w, r, handler)
	if t != nil {
		c, err := backend.Expand(t)
		if err != nil {
			util.LogAndReturnError(handler, http.StatusBadRequest, err, w)
			return
		}

		util.LogHandlerExitWithJSON(handler, w, c, http.StatusCreated)
		return
	}
}
開發者ID:shawnps,項目名稱:deployment-manager,代碼行數:16,代碼來源:deployments.go

示例12: createDeploymentHandlerFunc

func createDeploymentHandlerFunc(w http.ResponseWriter, r *http.Request) {
	handler := "manager: create deployment"
	util.LogHandlerEntry(handler, r)
	defer r.Body.Close()
	t := getTemplate(w, r, handler)
	if t != nil {
		d, err := backend.CreateDeployment(t)
		if err != nil {
			util.LogAndReturnError(handler, http.StatusBadRequest, err, w)
			return
		}

		util.LogHandlerExitWithJSON(handler, w, d, http.StatusCreated)
		return
	}
}
開發者ID:RamessesYin,項目名稱:deployment-manager,代碼行數:16,代碼來源:deployments.go

示例13: getDeploymentHandlerFunc

func getDeploymentHandlerFunc(w http.ResponseWriter, r *http.Request) {
	handler := "manager: get deployment"
	util.LogHandlerEntry(handler, r)
	name, err := getPathVariable(w, r, "deployment", handler)
	if err != nil {
		return
	}

	d, err := backend.GetDeployment(name)
	if err != nil {
		util.LogAndReturnError(handler, http.StatusBadRequest, err, w)
		return
	}

	util.LogHandlerExitWithJSON(handler, w, d, http.StatusOK)
}
開發者ID:RamessesYin,項目名稱:deployment-manager,代碼行數:16,代碼來源:deployments.go

示例14: getRegistryHandlerFunc

func getRegistryHandlerFunc(w http.ResponseWriter, r *http.Request) {
	handler := "manager: get registry"
	util.LogHandlerEntry(handler, r)
	registryName, err := getPathVariable(w, r, "registry", handler)
	if err != nil {
		return
	}

	cr, err := backend.GetRegistry(registryName)
	if err != nil {
		util.LogAndReturnError(handler, http.StatusBadRequest, err, w)
		return
	}

	util.LogHandlerExitWithJSON(handler, w, cr, http.StatusOK)
}
開發者ID:shawnps,項目名稱:deployment-manager,代碼行數:16,代碼來源:deployments.go

示例15: putDeploymentHandlerFunc

func putDeploymentHandlerFunc(w http.ResponseWriter, r *http.Request) {
	handler := "manager: update deployment"
	util.LogHandlerEntry(handler, r)
	defer r.Body.Close()
	name, err := getPathVariable(w, r, "deployment", handler)
	if err != nil {
		return
	}

	t := getTemplate(w, r, handler)
	if t != nil {
		d, err := backend.PutDeployment(name, t)
		if err != nil {
			util.LogAndReturnError(handler, http.StatusBadRequest, err, w)
			return
		}

		util.LogHandlerExitWithJSON(handler, w, d, http.StatusCreated)
	}
}
開發者ID:RamessesYin,項目名稱:deployment-manager,代碼行數:20,代碼來源:deployments.go


注:本文中的github.com/kubernetes/deployment-manager/util.LogHandlerExitWithJSON函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。