本文整理汇总了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)
}
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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))
}