mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-24 17:47:46 +01:00
Merge pull request #6176 from steven-zou/support_health_check_js
Support health check free call in job service
This commit is contained in:
commit
5d585c7c65
@ -63,13 +63,16 @@ func NewBaseRouter(handler Handler, authenticator Authenticator) Router {
|
|||||||
|
|
||||||
// ServeHTTP is the implementation of Router interface.
|
// ServeHTTP is the implementation of Router interface.
|
||||||
func (br *BaseRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
func (br *BaseRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
// Do auth
|
// No auth required for /stats as it is a health check endpoint
|
||||||
if err := br.authenticator.DoAuth(req); err != nil {
|
// Do auth for other services
|
||||||
authErr := errs.UnauthorizedError(err)
|
if req.URL.String() != fmt.Sprintf("%s/%s/stats", baseRoute, apiVersion) {
|
||||||
logger.Errorf("Serve http request '%s %s' failed with error: %s", req.Method, req.URL.String(), authErr.Error())
|
if err := br.authenticator.DoAuth(req); err != nil {
|
||||||
w.WriteHeader(http.StatusUnauthorized)
|
authErr := errs.UnauthorizedError(err)
|
||||||
w.Write([]byte(authErr.Error()))
|
logger.Errorf("Serve http request '%s %s' failed with error: %s", req.Method, req.URL.String(), authErr.Error())
|
||||||
return
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
|
w.Write([]byte(authErr.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Directly pass requests to the server mux.
|
// Directly pass requests to the server mux.
|
||||||
|
Loading…
Reference in New Issue
Block a user