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


Golang util.LogHandlerExit函數代碼示例

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


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

示例1: NewExpansionHandler

// NewExpansionHandler returns a route function that handles an incoming
// template expansion request, bound to the supplied expander.
func NewExpansionHandler(backend expander.Expander) restful.RouteFunction {
	return func(req *restful.Request, resp *restful.Response) {
		util.LogHandlerEntry("expandybird: expand", req.Request)
		template := &expander.Template{}
		if err := req.ReadEntity(&template); err != nil {
			logAndReturnErrorFromHandler(http.StatusBadRequest, err.Error(), resp)
			return
		}

		output, err := backend.ExpandTemplate(template)
		if err != nil {
			message := fmt.Sprintf("error expanding template: %s", err)
			logAndReturnErrorFromHandler(http.StatusBadRequest, message, resp)
			return
		}

		response, err := expander.NewExpansionResponse(output)
		if err != nil {
			message := fmt.Sprintf("error marshaling output: %s", err)
			logAndReturnErrorFromHandler(http.StatusBadRequest, message, resp)
			return
		}

		util.LogHandlerExit("expandybird", http.StatusOK, "OK", resp.ResponseWriter)
		resp.WriteEntity(response)
	}
}
開發者ID:RamessesYin,項目名稱:deployment-manager,代碼行數:29,代碼來源:service.go

示例2: getConfigurationHandlerFunc

func getConfigurationHandlerFunc(w http.ResponseWriter, r *http.Request) {
	handler := "resourcifier: get configuration"
	util.LogHandlerEntry(handler, r)
	rtype, err := getPathVariable(w, r, "type", handler)
	if err != nil {
		return
	}

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

	c := &common.Configuration{
		[]*common.Resource{
			{Name: rname, Type: rtype},
		},
	}

	output, err := backend.Configure(c, configurator.GetOperation)
	if err != nil {
		util.LogAndReturnError(handler, http.StatusBadRequest, err, w)
		return
	}

	util.LogHandlerExit(handler, http.StatusOK, output, w)
	util.WriteYAML(handler, w, []byte(output), http.StatusOK)
}
開發者ID:shawnps,項目名稱:deployment-manager,代碼行數:28,代碼來源:configurations.go

示例3: deleteConfigurationHandlerFunc

func deleteConfigurationHandlerFunc(w http.ResponseWriter, r *http.Request) {
	handler := "resourcifier: delete configuration"
	util.LogHandlerEntry(handler, r)
	defer r.Body.Close()
	c := getConfiguration(w, r, handler)
	if c != nil {
		if _, err := backend.Configure(c, configurator.DeleteOperation); err != nil {
			e := errors.New("cannot delete configuration: " + err.Error() + "\n")
			util.LogAndReturnError(handler, http.StatusBadRequest, e, w)
			return
		}

		w.WriteHeader(http.StatusNoContent)
		util.LogHandlerExit(handler, http.StatusNoContent, "No Content", w)
		return
	}

	util.LogHandlerExit(handler, http.StatusOK, "OK", w)
}
開發者ID:shawnps,項目名稱:deployment-manager,代碼行數:19,代碼來源:configurations.go

示例4: putConfigurationHandlerFunc

func putConfigurationHandlerFunc(w http.ResponseWriter, r *http.Request) {
	handler := "resourcifier: update configuration"
	util.LogHandlerEntry(handler, r)
	defer r.Body.Close()
	c := getConfiguration(w, r, handler)
	if c != nil {
		if _, err := backend.Configure(c, configurator.ReplaceOperation); err != nil {
			e := errors.New("cannot replace configuration: " + err.Error() + "\n")
			util.LogAndReturnError(handler, http.StatusBadRequest, e, w)
			return
		}

		util.LogHandlerExitWithYAML(handler, w, c, http.StatusCreated)
		return
	}

	util.LogHandlerExit(handler, http.StatusOK, "OK", w)
}
開發者ID:shawnps,項目名稱:deployment-manager,代碼行數:18,代碼來源:configurations.go

示例5: createConfigurationHandlerFunc

func createConfigurationHandlerFunc(w http.ResponseWriter, r *http.Request) {
	handler := "resourcifier: create configuration"
	util.LogHandlerEntry(handler, r)
	defer r.Body.Close()
	c := getConfiguration(w, r, handler)
	if c != nil {
		_, err := backend.Configure(c, configurator.CreateOperation)
		if err != nil {
			util.LogAndReturnError(handler, http.StatusBadRequest, err, w)
			return
		}

		util.LogHandlerExitWithYAML(handler, w, c, http.StatusCreated)
		return
	}

	util.LogHandlerExit(handler, http.StatusOK, "OK", w)
}
開發者ID:shawnps,項目名稱:deployment-manager,代碼行數:18,代碼來源:configurations.go

示例6: logAndReturnErrorFromHandler

func logAndReturnErrorFromHandler(statusCode int, message string, resp *restful.Response) {
	util.LogHandlerExit("expandybird: expand", statusCode, message, resp.ResponseWriter)
	resp.WriteError(statusCode, errors.New(message))
}
開發者ID:RamessesYin,項目名稱:deployment-manager,代碼行數:4,代碼來源:service.go


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