• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang util.LogHandlerEntry函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/kubernetes/deployment-manager/util.LogHandlerEntry函数的典型用法代码示例。如果您正苦于以下问题:Golang LogHandlerEntry函数的具体用法?Golang LogHandlerEntry怎么用?Golang LogHandlerEntry使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了LogHandlerEntry函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: 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


示例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: 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


示例4: 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


示例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: 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


示例7: 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


示例8: 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


示例9: 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


示例10: 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


示例11: 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


示例12: 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


示例13: getCredential

func getCredential(w http.ResponseWriter, r *http.Request, handler string) *common.RegistryCredential {
	util.LogHandlerEntry(handler, r)
	j, err := getJsonFromRequest(w, r, handler)
	if err != nil {
		return nil
	}

	t := &common.RegistryCredential{}
	if err := json.Unmarshal(j, t); err != nil {
		e := fmt.Errorf("%v\n%v", err, string(j))
		util.LogAndReturnError(handler, http.StatusBadRequest, e, w)
		return nil
	}

	return t
}
开发者ID:shawnps,项目名称:deployment-manager,代码行数:16,代码来源:deployments.go


示例14: 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


示例15: 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


示例16: 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


示例17: 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


示例18: 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


示例19: 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


示例20: 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



注:本文中的github.com/kubernetes/deployment-manager/util.LogHandlerEntry函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang util.LogHandlerExit函数代码示例发布时间:2022-05-23
下一篇:
Golang util.LogAndReturnError函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap