Skip to content

Commit

Permalink
Merge pull request #12932 from vvdvortsova/12821-fix-req-maybe-nil
Browse files Browse the repository at this point in the history
embed: Added a check for a nil value of the request in ServeHTTP method
  • Loading branch information
ptabor committed May 10, 2021
2 parents f571701 + c3303d9 commit 5f6f69c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server/embed/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,12 @@ type accessController struct {
}

func (ac *accessController) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
if req == nil {
http.Error(rw, "Request is nil", http.StatusBadRequest)
return
}
// redirect for backward compatibilities
if req != nil && req.URL != nil && strings.HasPrefix(req.URL.Path, "/v3beta/") {
if req.URL != nil && strings.HasPrefix(req.URL.Path, "/v3beta/") {
req.URL.Path = strings.Replace(req.URL.Path, "/v3beta/", "/v3/", 1)
}

Expand Down

0 comments on commit 5f6f69c

Please sign in to comment.