mirror of
https://github.com/goharbor/harbor.git
synced 2024-10-01 14:58:03 +02:00
Support health check free call in job service
Signed-off-by: Steven Zou <szou@vmware.com>
This commit is contained in:
parent
e7e2312e16
commit
8341aa14b0
@ -63,7 +63,9 @@ 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
|
||||||
|
// Do auth for other services
|
||||||
|
if req.URL.String() != fmt.Sprintf("%s/%s/stats", baseRoute, apiVersion) {
|
||||||
if err := br.authenticator.DoAuth(req); err != nil {
|
if err := br.authenticator.DoAuth(req); err != nil {
|
||||||
authErr := errs.UnauthorizedError(err)
|
authErr := errs.UnauthorizedError(err)
|
||||||
logger.Errorf("Serve http request '%s %s' failed with error: %s", req.Method, req.URL.String(), authErr.Error())
|
logger.Errorf("Serve http request '%s %s' failed with error: %s", req.Method, req.URL.String(), authErr.Error())
|
||||||
@ -71,6 +73,7 @@ func (br *BaseRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||||||
w.Write([]byte(authErr.Error()))
|
w.Write([]byte(authErr.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Directly pass requests to the server mux.
|
// Directly pass requests to the server mux.
|
||||||
br.router.ServeHTTP(w, req)
|
br.router.ServeHTTP(w, req)
|
||||||
|
Loading…
Reference in New Issue
Block a user