use kube-apiserver proxy if no kubesphere api endpoint provided (#2144)
This commit is contained in:
@@ -18,26 +18,38 @@ package api
|
||||
|
||||
import (
|
||||
"github.com/emicklei/go-restful"
|
||||
"k8s.io/klog"
|
||||
"net/http"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
func HandleInternalError(response *restful.Response, req *restful.Request, err error) {
|
||||
response.WriteError(http.StatusInternalServerError, err)
|
||||
_, fn, line, _ := runtime.Caller(1)
|
||||
klog.Errorf("%s:%d %v", fn, line, err)
|
||||
_ = response.WriteError(http.StatusInternalServerError, err)
|
||||
}
|
||||
|
||||
// HandleBadRequest writes http.StatusBadRequest and log error
|
||||
func HandleBadRequest(response *restful.Response, req *restful.Request, err error) {
|
||||
response.WriteError(http.StatusBadRequest, err)
|
||||
_, fn, line, _ := runtime.Caller(1)
|
||||
klog.Errorf("%s:%d %v", fn, line, err)
|
||||
_ = response.WriteError(http.StatusBadRequest, err)
|
||||
}
|
||||
|
||||
func HandleNotFound(response *restful.Response, req *restful.Request, err error) {
|
||||
response.WriteError(http.StatusNotFound, err)
|
||||
_, fn, line, _ := runtime.Caller(1)
|
||||
klog.Errorf("%s:%d %v", fn, line, err)
|
||||
_ = response.WriteError(http.StatusNotFound, err)
|
||||
}
|
||||
|
||||
func HandleForbidden(response *restful.Response, req *restful.Request, err error) {
|
||||
response.WriteError(http.StatusForbidden, err)
|
||||
_, fn, line, _ := runtime.Caller(1)
|
||||
klog.Errorf("%s:%d %v", fn, line, err)
|
||||
_ = response.WriteError(http.StatusForbidden, err)
|
||||
}
|
||||
|
||||
func HandleConflict(response *restful.Response, req *restful.Request, err error) {
|
||||
response.WriteError(http.StatusConflict, err)
|
||||
_, fn, line, _ := runtime.Caller(1)
|
||||
klog.Errorf("%s:%d %v", fn, line, err)
|
||||
_ = response.WriteError(http.StatusConflict, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user